Faster dictionaries?

Ian Piumarta piumarta at gmail.com
Thu Jul 19 18:41:01 UTC 2007


On Jul 19, 2007, at 5:10 AM, sig wrote:

> its a scratch implementation of dictionaries using linked list of  
> associations.

I think the two 'at:ifAbsent:' methods neglect to send #value to the  
errorBlock?

Otherwise the lookup performance ain't too shabby for relatively  
small tallies.  (For anyone who can decode this sentence: BucketDict  
is almost as fast as Pepsi's SlotDictionary when used as the basis  
for lexical environments in the Jolt compiler.  This is my usual  
'quasi-realistic' benchmark for a Dictionary.)

One classic optimisation would be to use an ArrayedCollection of some  
kind (instead of a linked list) for the buckets.  When #findKeyOrNil:  
hits and the association is not the first element in the bucket then  
exchange it with the element immediately preceding it.  Associations  
related to popular keys will gradually migrate to the front of their  
buckets.

Cheers,
Ian




More information about the Squeak-dev mailing list