Consolidate the occurrances of the prime used as the multiplier when hashing

to a single #define instead of having several copies in several files.

This excludes the Modules/ tree (datetime and expat both have a copy
for their own purposes with no need for it to be the same).
This commit is contained in:
Gregory P. Smith 2012-01-14 15:31:34 -08:00
parent 515687a7ed
commit 63e6c3222f
4 changed files with 7 additions and 4 deletions

View file

@ -881,7 +881,7 @@ bytes_hash(PyBytesObject *a)
p = (unsigned char *) a->ob_sval;
x = *p << 7;
while (--len >= 0)
x = (1000003*x) ^ *p++;
x = (_PyHASH_MULTIPLIER*x) ^ *p++;
x ^= Py_SIZE(a);
if (x == -1)
x = -2;

View file

@ -315,7 +315,7 @@ tuplehash(PyTupleObject *v)
register Py_hash_t x, y;
register Py_ssize_t len = Py_SIZE(v);
register PyObject **p;
Py_hash_t mult = 1000003L;
Py_hash_t mult = _PyHASH_MULTIPLIER;
x = 0x345678L;
p = v->ob_item;
while (--len >= 0) {

View file

@ -7666,7 +7666,7 @@ unicode_hash(PyUnicodeObject *self)
p = self->str;
x = *p << 7;
while (--len >= 0)
x = (1000003*x) ^ *p++;
x = (_PyHASH_MULTIPLIER*x) ^ *p++;
x ^= Py_SIZE(self);
if (x == -1)
x = -2;