The Trunk: Kernel-ul.382.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-ul.382.mcz

commits-2
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.382.mcz

==================== Summary ====================

Name: Kernel-ul.382
Author: ul
Time: 25 January 2010, 10:40:19.44 pm
UUID: 0741847a-6bd5-c145-aa63-3c5e598d1742
Ancestors: Kernel-dtl.381

In MethodDictionary
- cosmetic changes: use #ifNotNil: if possible
- ensure that #rehashWithoutBecome doesn't send #become:, making #rehashAllInstances a lot faster
- ensure that #removeAll preserves the capacity
- deprecated #methodArray, it's the same as #array
- new comment for #new

=============== Diff against Kernel-dtl.381 ===============

Item was changed:
  ----- Method: MethodDictionary>>postCopy (in category 'copying') -----
  postCopy
 
+ array := array copy!
- array := array shallowCopy!

Item was changed:
  ----- Method: MethodDictionary>>rehashWithoutBecome (in category 'private') -----
  rehashWithoutBecome
 
+ | newInstance |
+ newInstance := self species new: self basicSize - 1. "Make sure it has the same capacity"
+ 1 to: self basicSize do: [ :index |
+ (self basicAt: index) ifNotNil: [ :key |
+ newInstance at: key put: (array at: index) ] ].
+ ^newInstance!
- | newSelf |
- newSelf := self species new: self size.
- 1 to: self basicSize do: [ :i |
- | key |
- (key := self basicAt: i) ifNotNil: [
- newSelf at: key put: (array at: i) ] ].
- ^newSelf!

Item was changed:
  ----- Method: MethodDictionary class>>new (in category 'instance creation') -----
  new
+ "Create a new instance with 32 slots."
- "change the default size to be a bit bigger to help reduce the number of #grows while filing in"
 
  ^self new: 16!

Item was changed:
  ----- Method: MethodDictionary>>associationsDo: (in category 'enumeration') -----
  associationsDo: aBlock
 
  tally = 0 ifTrue: [ ^self ].
  1 to: self basicSize do: [ :i |
+ (self basicAt: i) ifNotNil: [ :key |
- | key |
- (key := self basicAt: i) ifNotNil: [
  aBlock value: (Association key: key value: (array at: i)) ] ]!

Item was changed:
  ----- Method: MethodDictionary>>removeAll (in category 'removing') -----
  removeAll
  "This provides a faster way than repeated become.
  a single become is still in use to prevent system crash."
 
  | newSelf |
  tally = 0 ifTrue: [^self].
+ newSelf := self species new: self basicSize - 1.  "This will preserve the capacity"
- newSelf := self species new: self size.  "This will preserve the capacity"
  self become: newSelf!

Item was changed:
  ----- Method: MethodDictionary>>keysDo: (in category 'enumeration') -----
  keysDo: aBlock
 
  tally = 0 ifTrue: [ ^self ].
  1 to: self basicSize do: [ :i |
+ (self basicAt: i) ifNotNil: [ :key |
- | key |
- (key := self basicAt: i) ifNotNil: [
  aBlock value: key ] ]!

Item was changed:
  ----- Method: MethodDictionary>>keysAndValuesDo: (in category 'enumeration') -----
  keysAndValuesDo: aBlock
  "Enumerate the receiver with all the keys and values passed to the block"
 
  tally = 0 ifTrue: [^ self].
  1 to: self basicSize do: [ :i |
+ (self basicAt: i) ifNotNil: [ :key |
- | key |
- (key := self basicAt: i) ifNotNil: [
  aBlock value: key value: (array at: i) ] ]!

Item was changed:
  ----- Method: MethodDictionary>>grow (in category 'private') -----
  grow
 
  | newSelf |
  newSelf := self species new: self basicSize.  "This will double the size"
  1 to: self basicSize do: [ :i |
+ (self basicAt: i) ifNotNil: [ :key |
- | key |
- (key := self basicAt: i) ifNotNil: [
  newSelf at: key put: (array at: i) ] ].
  self become: newSelf!

Item was changed:
  ----- Method: MethodDictionary>>methodArray (in category 'private') -----
  methodArray
+
+ self deprecated: 'Use #array'.
-
  ^array!

Item was changed:
  ----- Method: MethodDictionary>>valuesDo: (in category 'enumeration') -----
  valuesDo: aBlock
 
  tally = 0 ifTrue: [ ^self ].
  1 to: self basicSize do: [ :i |
+ (array at: i) ifNotNil: [ :value |
- | value |
- (value := array at: i) ifNotNil: [
  aBlock value: value ] ]!