[squeak-dev] The Trunk: Collections-ul.308.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Feb 17 21:04:53 UTC 2010


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

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

Name: Collections-ul.308
Author: ul
Time: 17 February 2010, 8:43:52.85 pm
UUID: 2de68222-ce83-6945-990f-bea94a0c857c
Ancestors: Collections-ar.307

- somewhat faster finalization

=============== Diff against Collections-ar.307 ===============

Item was changed:
  ----- Method: WeakKeyAssociation>>key (in category 'accessing') -----
  key
+ 
+ 	^key ifNotNil: [ key at: 1 ]!
- 	^key isNil
- 		ifTrue:[nil]
- 		ifFalse:[key at: 1]!

Item was changed:
  ----- Method: WeakKeyDictionary>>finalizeValues (in category 'finalization') -----
  finalizeValues
+ 	"Remove and finalize all elements which have nil key"
- 	"remove all nil keys and rehash the receiver afterwards"
  	
+ 	|  cleanUpAfterRemove |
+ 	tally = 0 ifTrue: [ ^self ].
+ 	cleanUpAfterRemove := false.
+ 	1 to: array size do: [ :index |
+ 		(array at: index) 
+ 			ifNil: [ cleanUpAfterRemove := false ]
+ 			ifNotNil: [ :element |
+ 				element key
+ 					ifNil: [
+ 						finalizer ifNotNil: [ finalizer value: element value ].
+ 						array at: index put: nil.
+ 						tally := tally - 1.
+ 						cleanUpAfterRemove := true ]
+ 					ifNotNil: [ :key |
+ 						cleanUpAfterRemove ifTrue: [
+ 							| newIndex |
+ 							(newIndex := self scanFor: key) = index ifFalse: [
+ 								array 
+ 									at: newIndex put: element;
+ 									at: index put: nil ] ] ] ] ]!
- 	self rehash!

Item was changed:
  ----- Method: WeakKeyDictionary>>fixCollisionsFrom: (in category 'private') -----
  fixCollisionsFrom: start
  	"The element at start has been removed and replaced by nil.
  	This method moves forward from there, relocating any entries
  	that had been placed below due to collisions with this one."
  
  	| element index |
  	index := start.
  	[ (element := array at: (index := index \\ array size + 1)) == nil ] whileFalse: [
  		element key
  			ifNil: [ 
  				finalizer ifNotNil: [ finalizer value: element value ].
  				array at: index put: nil.
  				tally := tally - 1 ]
  			ifNotNil: [ :key | "Don't let the key go away"
  				| newIndex |
  				(newIndex := self scanFor: key) = index ifFalse: [
+ 					array 
+ 						at: newIndex put: element;
+ 						at: index put: nil ] ] ]!
- 					array swap: index with: newIndex ] ] ]!




More information about the Squeak-dev mailing list