summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authoranimalize <animalize@users.noreply.github.com>2019-01-02 12:16:06 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-01-02 12:16:06 (GMT)
commita1d14253066f7dd60cfb465c6511fa565f312b42 (patch)
tree206fb1c36b7361468fb4f1a68197a90b4d50f015 /Objects
parentf8b534477a2a51d85ea1663530f685f805f2b247 (diff)
downloadcpython-a1d14253066f7dd60cfb465c6511fa565f312b42.zip
cpython-a1d14253066f7dd60cfb465c6511fa565f312b42.tar.gz
cpython-a1d14253066f7dd60cfb465c6511fa565f312b42.tar.bz2
bpo-35636: Remove redundant check in unicode_hash(). (GH-11402)
_Py_HashBytes() does the check for empty string.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 06338fa..f1dcfe9 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -11656,7 +11656,6 @@ unicode_getitem(PyObject *self, Py_ssize_t index)
static Py_hash_t
unicode_hash(PyObject *self)
{
- Py_ssize_t len;
Py_uhash_t x; /* Unsigned for defined overflow behavior. */
#ifdef Py_DEBUG
@@ -11666,15 +11665,7 @@ unicode_hash(PyObject *self)
return _PyUnicode_HASH(self);
if (PyUnicode_READY(self) == -1)
return -1;
- len = PyUnicode_GET_LENGTH(self);
- /*
- We make the hash of the empty string be 0, rather than using
- (prefix ^ suffix), since this slightly obfuscates the hash secret
- */
- if (len == 0) {
- _PyUnicode_HASH(self) = 0;
- return 0;
- }
+
x = _Py_HashBytes(PyUnicode_DATA(self),
PyUnicode_GET_LENGTH(self) * PyUnicode_KIND(self));
_PyUnicode_HASH(self) = x;