Reimplementing WeakKeyDictionary

Andreas Raab andreas.raab at gmx.de
Mon Mar 19 06:50:15 UTC 2007


Martin v. Löwis wrote:
> The next invocation of fullCheck will see that there are way too many
> expired entries in the dictionary, and rehash it.

Oh, it does! I didn't notice that. In this case, my point is of course moot.

>> Nothing that a good #rehash can't fix of course, but I'm wondering if 
>> at some point the WKD shouldn't recognize the ratio of 
>> expired/free/used slots and act accordingly. 
> 
> Ah, it does: if 4*expired > array size, it rehashes (in fullCheck). The
> precise percentage may be debatable, and it may be an option to also
> consider the relationship of expired and tally, but it will definitely
> rehash from time to time (and growing will drop expired entries, too).

Right. Wasn't careful enough reading the code. Nevermind ;-)

Brief Q: You didn't explicitly specify what license those changes are 
under. Would you be amendable to using MIT-style license for it? (it 
would allow me to use the code trivially in Croquet)

Cheers,
   - Andreas



More information about the Squeak-dev mailing list