diff options
author | Gregory P. Smith <greg@krypto.org> | 2012-01-14 22:31:13 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2012-01-14 22:31:13 (GMT) |
commit | 5831bd2f3bdc9b07912fb939afc79d04910971e8 (patch) | |
tree | 601c711bd7caf575130f842ac86f3d7b26085f3a /Modules/_datetimemodule.c | |
parent | 0ea3ea5e6954635714d028cb174d911ba59b7862 (diff) | |
download | cpython-5831bd2f3bdc9b07912fb939afc79d04910971e8.zip cpython-5831bd2f3bdc9b07912fb939afc79d04910971e8.tar.gz cpython-5831bd2f3bdc9b07912fb939afc79d04910971e8.tar.bz2 |
Remove an unnecessary extra copy of the bytes hash function.
This copy also had a bug in it, it fails to incorporate the length
into the hash by using it as the loop variable so it'll always be -1
by the time it is XORed in.
As such: I'm doing this only in Python 3.3 and not backporting as it
would change the existing hash behavior of datetime objects.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r-- | Modules/_datetimemodule.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b384233..3b0b362 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -2755,24 +2755,10 @@ date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw) return clone; } -/* - Borrowed from stringobject.c, originally it was string_hash() -*/ static Py_hash_t generic_hash(unsigned char *data, int len) { - register unsigned char *p; - register Py_uhash_t x; - - p = (unsigned char *) data; - x = (Py_uhash_t)*p << 7; - while (--len >= 0) - x = (1000003U*x) ^ (Py_uhash_t)*p++; - x ^= (Py_uhash_t)len; - if (x == -1) - x = -2; - - return x; + return _Py_HashBytes(data, len); } |