[squeak-dev] The Trunk: Kernel-ul.631.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Sep 27 16:52:46 UTC 2011


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

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

Name: Kernel-ul.631
Author: ul
Time: 27 September 2011, 6:47:40.645 pm
UUID: 7793f80d-42dc-2a45-afc1-67ce003aba45
Ancestors: Kernel-eem.630, Kernel-ul.630

Merged.

=============== Diff against Kernel-eem.630 ===============

Item was changed:
  ----- Method: MethodDictionary class>>new (in category 'instance creation') -----
  new
+ 	"Create a new instance with 32 slots, which can hold at most 24 methods before growing is necessary."
- 	"Create a new instance with 32 slots. See the comment of #sizeFor: why the argument is 16."
  	
+ 	^self newForCapacity: 32!
- 	^self new: 16!

Item was changed:
  ----- Method: MethodDictionary class>>new: (in category 'instance creation') -----
  new: numberOfElements
+ 	"Create an instance large enough to hold numberOfElements methods without growing."
- 	"Create an instance large enough to hold numberOfElements without growing. Note that the basic size must be a power of 2. It is VITAL (see grow) that size gets doubled if numberOfElements is a power of 2"
  	
+ 	^self newForCapacity: (self sizeFor: numberOfElements)!
- 	| size |
- 	size := self sizeFor: numberOfElements.
- 	^(self basicNew: size) initialize: size!

Item was added:
+ ----- Method: MethodDictionary class>>newForCapacity: (in category 'private') -----
+ newForCapacity: capacity
+ 	"Create an instance with the given capacity which must be a power of two."
+ 	
+ 	^(self basicNew: capacity) initialize: capacity!

Item was changed:
  ----- Method: MethodDictionary class>>sizeFor: (in category 'sizing') -----
  sizeFor: numberOfElements
  	"Return the minimum capacity of a dictionary that can hold numberOfElements elements. At least 25% of the array must be empty and the return value must be a power of 2."
  
+ 	^(numberOfElements * 4 // 3) asLargerPowerOfTwo!
- 	^1 bitShift: (numberOfElements * 4 // 3) highBit!

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

Item was changed:
  ----- Method: MethodDictionary>>rehash (in category 'private') -----
  rehash 
  	
  	| newInstance |
+ 	newInstance := self species newForCapacity: self basicSize.
- 	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) ] ].
  	self copyFrom: newInstance!

Item was changed:
  ----- Method: MethodDictionary>>removeAll (in category 'removing') -----
  removeAll
+ 	"Remove all elements from this collection. Preserve the capacity"
- 	"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 newForCapacity: self basicSize.
- 	newSelf := self species new: self basicSize - 1.  "This will preserve the capacity"
  	self copyFrom: newSelf!




More information about the Squeak-dev mailing list