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

commits at source.squeak.org commits at source.squeak.org
Tue Dec 1 04:37:58 UTC 2009


Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.217.mcz

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

Name: Collections-ul.217
Author: ul
Time: 30 November 2009, 4:47:54 am
UUID: a67f6177-4f3f-bd41-af32-c1881c7f0e20
Ancestors: Collections-ul.216

Replace sends of #scanForEmptySlotFor: with #scanFor:. This enables atomic changes of the hash implementation.

=============== Diff against Collections-dtl.214 ===============

Item was added:
+ ----- Method: CollectionRehashingUtility>>rehashAllSets (in category 'private - rehashing') -----
+ rehashAllSets
+ 
+ 	HashedCollection rehashAll!

Item was added:
+ ----- Method: CollectionRehashingUtility class>>rehashBecause: (in category 'rehashing') -----
+ rehashBecause: aSymbol
+ 
+ 	self new rehashBecause: aSymbol!

Item was changed:
  ----- Method: KeyedSet>>noCheckNoGrowFillFrom: (in category 'private') -----
  noCheckNoGrowFillFrom: anArray
  	"Add the elements of anArray except nils to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
  
  	1 to: anArray size do: [ :index |
  		| object |
  		(object := anArray at: index) ifNotNil: [
  			array
+ 				at: (self scanFor: (keyBlock value: object))
- 				at: (self scanForEmptySlotFor: (keyBlock value: object))
  				put: object ] ]!

Item was added:
+ ----- Method: CollectionRehashingUtility>>changes (in category 'private - accessing') -----
+ changes
+ 
+ 	^changes!

Item was added:
+ ----- Method: CollectionRehashingUtility>>quickRehashAllSets (in category 'private - rehashing') -----
+ quickRehashAllSets
+ 
+ 	HashedCollection withAllSubclassesDo:
+ 		[:class |
+ 			class = MethodDictionary ifFalse:
+ 				[class allInstances do: [:each | each rehash]]
+ 		]!

Item was added:
+ ----- Method: CollectionRehashingUtility class>>new (in category 'instance creation') -----
+ new
+ 
+ 	self current notNil ifTrue: [^self current].
+ 	self current: super new initialize.
+ 	^self current!

Item was changed:
  ----- Method: WeakSet>>noCheckNoGrowFillFrom: (in category 'private') -----
  noCheckNoGrowFillFrom: anArray
  	"Add the elements of anArray except nils and flag to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
  
  	tally := 0.
  	1 to: anArray size do: [ :index |
  		| object |
  		((object := anArray at: index) == flag or: [
  			object == nil ]) ifFalse: [ 
  				array
+ 					at: (self scanFor: object)
- 					at: (self scanForEmptySlotFor: object)
  					put: object.
  				tally := tally + 1 ] ]!

Item was changed:
  ----- Method: Set>>noCheckNoGrowFillFrom: (in category 'private') -----
  noCheckNoGrowFillFrom: anArray
  	"Add the elements of anArray except nils to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
  
  	1 to: anArray size do: [ :index |
  		| object |
  		(object := anArray at: index) ifNotNil: [
  			array
+ 				at: (self scanFor: object)
- 				at: (self scanForEmptySlotFor: object)
  				put: object ] ]!

Item was changed:
  ----- Method: Dictionary>>noCheckNoGrowFillFrom: (in category 'private') -----
  noCheckNoGrowFillFrom: anArray
  	"Add the elements of anArray except nils to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
  
  	1 to: anArray size do: [ :index |
  		| object |
  		(object := anArray at: index) ifNotNil: [
  			array
+ 				at: (self scanFor: object key)
- 				at: (self scanForEmptySlotFor: object key)
  				put: object ] ]!

Item was changed:
  ----- Method: WeakKeyDictionary>>noCheckNoGrowFillFrom: (in category 'private') -----
  noCheckNoGrowFillFrom: anArray
  	"Add the elements of anArray except nils and flag to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
  
  	tally := 0.
  	1 to: anArray size do:[ :i |
  		| association |
  		(association := anArray at: i) ifNotNil: [
  			array
+ 				at: (self scanFor: association key)
- 				at: (self scanForEmptySlotFor: association key)
  				put: association.
  			tally := tally + 1 ] ]!

Item was added:
+ ----- Method: CollectionRehashingUtility>>quickRehashBecause: (in category 'rehashing') -----
+ quickRehashBecause: aSymbol
+ 
+ 	(self changes includes: aSymbol) ifTrue: [^self].
+ 	self changes add: aSymbol.
+ 	self quickRehashAllSets!

Item was added:
+ ----- Method: CollectionRehashingUtility class>>current: (in category 'private - accessing') -----
+ current: anInstance
+ 
+ 	current := anInstance!

Item was changed:
  ----- Method: WeakSet>>do: (in category 'public') -----
  do: aBlock
- 	| each |
  
  	tally = 0 ifTrue: [^self].
+ 	array do: [ :each |
+ 		(each == nil or: [each == flag])
+ 			ifFalse: [ aBlock value: each ] ]!
- 	1 to: array size do:
- 		[:index |
- 			((each := array at: index) == nil or: [each == flag])
- 				ifFalse: [aBlock value: each]
- 		]!

Item was changed:
  ----- Method: WeakKeyDictionary>>finalizeValues: (in category 'finalization') -----
  finalizeValues: finiObjects
  	"Remove all associations with key == nil and value is in finiObjects.
  	This method is folded with #rehash for efficiency."
  	
  	| oldArray |
  	oldArray := array.
  	array := Array new: oldArray size.
  	tally := 0.
  	1 to: array size do:[ :i |
  		| association |
  		(association := oldArray at: i) ifNotNil: [
  			| key |
  			((key := association key) == nil and: [ "Don't let the key go away"
  				finiObjects includes: association value ])
  					ifFalse: [
  						array 
+ 							at: (self scanFor: key) 
- 							at: (self scanForEmptySlotFor: key) 
  							put: association.
  						tally := tally + 1 ] ] ]!

Item was changed:

Item was added:
+ ----- Method: CollectionRehashingUtility>>rehashBecause: (in category 'rehashing') -----
+ rehashBecause: aSymbol
+ 
+ 	(self changes includes: aSymbol) ifTrue: [^self].
+ 	self changes add: aSymbol.
+ 	self rehashAllSets.
+ 	self rehashSymbolTable!

Item was changed:
  ----- Method: WeakKeyToCollectionDictionary>>noCheckNoGrowFillFrom: (in category 'as yet unclassified') -----
  noCheckNoGrowFillFrom: anArray
  	"Add the elements of anArray except nils and associations with empty collections (or with only nils) to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
  
  	tally := 0.
  	1 to: anArray size do:[ :i |
  		| association cleanedValue |
  		((association := anArray at: i) == nil or: [ 
  			(cleanedValue := association value copyWithout: nil) isEmpty ]) 
  				ifFalse: [
  					association value: cleanedValue.
  					array
+ 						at: (self scanFor: association key)
- 						at: (self scanForEmptySlotFor: association key)
  						put: association.
  					tally := tally + 1 ] ]!

Item was changed:
  ----- Method: Dictionary>>associationsDo: (in category 'enumerating') -----
  associationsDo: aBlock 
  	"Evaluate aBlock for each of the receiver's elements (key/value 
  	associations)."
  
  	tally = 0 ifTrue: [ ^self].
+ 	array do: [ :each | each ifNotNil: [ aBlock value: each ] ]!
- 	1 to: array size do: [ :index |
- 		| each |
- 		(each := array at: index)
- 			ifNotNil: [ aBlock value: each ] ]!

Item was added:
+ ----- Method: CollectionRehashingUtility class>>current (in category 'private - accessing') -----
+ current
+ 
+ 	^current!

Item was added:
+ ----- Method: CollectionRehashingUtility>>initialize (in category 'private') -----
+ initialize
+ 
+ 	self changes: OrderedCollection new!

Item was added:
+ ----- Method: CollectionRehashingUtility>>rehashSymbolTable (in category 'private - rehashing') -----
+ rehashSymbolTable
+ 
+ 	Symbol rehash!

Item was changed:
  ----- Method: Set>>do: (in category 'enumerating') -----
  do: aBlock 
  
  	tally = 0 ifTrue: [ ^self ].
+ 	array do: [ :each | each ifNotNil: [ aBlock value: each ] ]!
- 	1 to: array size do: [ :index |
- 		| each |
- 		(each := array at: index)
- 			ifNotNil: [ aBlock value: each ] ]!

Item was added:
+ Object subclass: #CollectionRehashingUtility
+ 	instanceVariableNames: 'changes'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'Collections-Unordered'!
+ CollectionRehashingUtility class
+ 	instanceVariableNames: 'current'!

Item was added:
+ ----- Method: CollectionRehashingUtility class>>quickRehashBecause: (in category 'rehashing') -----
+ quickRehashBecause: aSymbol
+ 
+ 	self new quickRehashBecause: aSymbol!

Item was added:
+ ----- Method: CollectionRehashingUtility>>changes: (in category 'private - accessing') -----
+ changes: aCollection
+ 	"aCollection must not be a hashed collection"
+ 
+ 	changes := aCollection!




More information about the Squeak-dev mailing list