A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ul.441.mcz==================== Summary ====================
Name: Kernel-ul.441
Author: ul
Time: 13 April 2010, 12:15:38.206 am
UUID: 060bac40-d722-4f46-b29e-49c1926243b6
Ancestors: Kernel-cmm.440
- #compact protocol for MethodDictionary
=============== Diff against Kernel-cmm.440 ===============
Item was added:
+ ----- Method: MethodDictionary>>compact (in category 'private') -----
+ compact
+ "Make sure that I have the highest possible load factor (at least 50%)."
+
+ self become: self compactWithoutBecome!
Item was changed:
----- Method: MethodDictionary class>>rehashAllInstances (in category 'initialization') -----
rehashAllInstances
| instances newInstances |
instances := self allInstances asArray.
+ newInstances := self allInstances collect: #rehashWithoutBecome.
- newInstances := self allInstances collect: [ :each | each rehashWithoutBecome ].
instances elementsExchangeIdentityWith: newInstances!
Item was changed:
----- Method: MethodDictionary class>>compactAllInstances (in category 'initialization') -----
+ compactAllInstances
- compactAllInstances "MethodDictionary compactAllInstances"
- "Compacts all MethodDictionaries to save space"
+ | instances newInstances |
+ instances := self allInstances asArray.
+ newInstances := self allInstances collect: #compactWithoutBecome.
+ instances elementsExchangeIdentityWith: newInstances!
- | oldInstances newInstances |
- oldInstances := self allInstances.
- newInstances := oldInstances collect:[:md|
- (self new: md size)
- compactCopyFrom: md;
- yourself].
- oldInstances elementsForwardIdentityTo: newInstances.
- !
Item was added:
+ ----- Method: MethodDictionary>>compactWithoutBecome (in category 'private') -----
+ compactWithoutBecome
+ "Return a copy of self which has the highest possible load factor (at least 50%)."
+
+ | newSelf |
+ newSelf := self class new: self size.
+ self keysAndValuesDo: [ :key :value |
+ newSelf at: key put: value ].
+ ^newSelf!
Item was removed:
- ----- Method: MethodDictionary>>compactCopyFrom: (in category 'private') -----
- compactCopyFrom: sourceMD
- "Copy the contents of source dictionary without growing"
-
- sourceMD keysAndValuesDo:[:key :value| | index |
- index := self scanFor: key.
- (self basicAt: index) ifNotNil:[self error: 'Something is horribly broken'].
- self basicAt: index put: key.
- array at: index put: value.
- tally := tally + 1.
- ].
- self size = self capacity ifTrue:[self grow]. "grow only if we reach capacity"
- !