[FIX] Hash

Andres Valloud avalloud at exobox.com
Fri Aug 4 21:56:35 UTC 2000


Hi.

Removes Symbol>>hash.
This is done since now symbols may be equal to strings and viceversa.
When they were equal, though, their hashes were not and that's not good.

Fixing this brought up some issues with the Interpreter. When the C code
is generated, some methods are inlined. Such inlined methods have local
variable names that mask global variable names. There is a check for
this (CCodeGenerator>>prepareMethods). The methods dictionary had symbol
keys, but it was queried for strings. Since the hashes for equal
variable names were different, those overlapping names were never
reported as errors by the CCodeGenerator. We changed the names of the
local variables by prefixing them with 'local'.

Also removes String>>hash. The previous implementations could provide
only 14 bits of hash, and this was just at its best. It did not spread
hash values enough either, so just about 12 bits were being used by all
the Strings in the system. The new implementation of hash for Strings
provides an excellent hash mentioned by Mark van Gulik, and it is now
used in more places through the Collection hierarchy (check
ByteArray>>hash, SequenceableCollection>>hash and Collection>>hash).

Also reimplements Fraction>>hash so that it does not answer
LargeIntegers. A small method called hashMultiply was added to
SmallInteger to keep things clean. A convenient method was also added to
Set class to rehash all sets except MethodDictionaries (takes too long
and they are not affected by #hash).

Finally, do not edit or fileOut this changeset! It contains hand made
postscripts and initialization code that will rehash all Sets and
Dictionaries in your system.

A quick check to see if this changeset did its work properly is to do
the following:
        * Try to get the Set class by typing 'Set' in a workspace and
then doing a print-it
        * Open a workspace

If that works, you are in good shape.

Andres.

PS: Needless to say, this changeset has been tested :)))...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SqR-BadHashFix.1.cs.gz
Type: application/x-gzip
Size: 3727 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000804/011a865f/SqR-BadHashFix.1.cs.bin


More information about the Squeak-dev mailing list