weak key dictionary

"Martin v. Löwis" martin at v.loewis.de
Wed Mar 28 08:33:59 UTC 2007


> I've managed to create a workspace script that reproduces the problem
> in a stock image.

Thanks for the tests. I found the problem: it was giving up on finding
a new slot too early. Attached is a fix; please let me know how it goes.

I will produce a new patch set.

Regards,
Martin
-------------- next part --------------
'From Squeak3.9 of 7 November 2006 [latest update: #7067] on 28 March 2007 at 10:28:47 am'!

!WeakKeyDictionary methodsFor: 'finalization' stamp: 'mvl 3/28/2007 10:26'!
noCheckAdd: anAssociation
	"Add anAssociation to the receiver. Discard expired associations. Put nil keys at the beginning."
	
	| key |
	
	key := anAssociation key. "Hold on to the key during this method"

	anAssociation expired ifFalse:[
		key ifNotNil:[
			super noCheckAdd: anAssociation
		] ifNil: [
			1 to: array size do:[:n|
				(array at: n) ifNil:[
					array at: n put: anAssociation. 
					tally := tally + 1.
					^self
				].
			].
			self error: 'could not find an empty slot.'
		].
	].! !


More information about the Squeak-dev mailing list