Hashing
Pat Caudill
patc at teleport.com
Fri Apr 17 20:31:49 UTC 1998
>If saving memory isn't a priority, there is always the Self way of
>hashing. Dedicate some 12 to 16 bits in the header of each object
>and fill it in from some counter or random number generator when
>the object is created and never change it after that.
>
>Of course, given Squeak's compact headers I don't think this is
>the way to go here.
You don't have to do it that way. You have only 2 bits for a hash. They
start off in state "no hash". As soon as you take the (larger hash) of
the object you put the hash in a look aside table and mark the object as
"hash taken". As soon as the grabage collector gets room (moves the
object, or deallocates the object behind it) the has is moved to the end
of the object and make the tags "hash attached".
Alas this wont keep the invariant that objects that compare equal hash
equal if the object hash depends on the contents and the object is
modified after the hash is first taken.
Pat Caudill
More information about the Squeak-dev
mailing list
|