HashBits, a lazy way
Tim Rowledge
tim at sumeru.stanford.edu
Wed Jul 9 23:53:52 UTC 2003
Hannes Hirzel <hannes.hirzel.squeaklist at bluewin.ch> wrote:
> > Now the optimization is that the identiy hash is rarely used because
> > most classes have hashs, and we only
> > need to do the hash for storing the item in a Set. IE doing
> > (1.0+2.0)*3.0 generates hashs on all the objects, plus
> > working objects. This takes time.
>
> I do not understand why (1.0+2.0)*3.0 generates hashs on all the
> objects. What does this expression mean in this context?
Instantiating a Float object for the answer to
1.0 + 2.0
involves filling in the hash value for that object, then instantiating
another FLoat for the answer to
3.0 * 3.0
does it again. The intermediate answer is trashed straight away. Thus
there are two cases of hashes being put into objects 'needlessly'. I can
imagine it saving a tiny amount of time to avoid it. However, save a
tiny amount of time in a lot of places and it adds up surprisingly
quickly!
tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
E Pluribus UNIX.
More information about the Squeak-dev
mailing list
|