[ENH] Ten Percent Faster Morphic! (with conversion)

Lex Spoon lex at cc.gatech.edu
Mon Aug 5 18:39:29 UTC 2002


> Could we make all really small hashed structures do linear searches?
> 
> - Stephen


You beat me to it!  With a little refactoring, you can put this strategy
in Set and make every hashed collection do it.  It will be a smidgen
slower, probably, than using an OrderedCollection.  But then you don't
have to manually figure out which of your collections will be small and
write uglier code to manage them.  Furthermore, you don't have to worry
about performance when the collections grow.

One idea, by the way, is to use an object to hold the searching and placement
strategy. Then you replace al the "if size < 4" statements by a polymorphic call
to the strategy object.  In fact, if you look up Strategy (I think it's Strategy) in
the design patterns book, then a very relevant example pops up.  :)


-Lex



More information about the Squeak-dev mailing list