Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(179333)

Unified Diff: Objects/bytesobject.c

Issue 13411: Hashable memoryviews
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_sys.py ('k') | Objects/memoryobject.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -860,22 +860,11 @@ bytes_richcompare(PyBytesObject *a, PyBy
static Py_hash_t
bytes_hash(PyBytesObject *a)
{
- register Py_ssize_t len;
- register unsigned char *p;
- register Py_uhash_t x;
-
- if (a->ob_shash != -1)
- return a->ob_shash;
- len = Py_SIZE(a);
- p = (unsigned char *) a->ob_sval;
- x = (Py_uhash_t)*p << 7;
- while (--len >= 0)
- x = (1000003U*x) ^ (Py_uhash_t)*p++;
- x ^= (Py_uhash_t)Py_SIZE(a);
- if (x == -1)
- x = -2;
- a->ob_shash = x;
- return x;
+ if (a->ob_shash == -1) {
+ /* Can't fail */
+ a->ob_shash = _Py_HashBytes((unsigned char *) a->ob_sval, Py_SIZE(a));
+ }
+ return a->ob_shash;
}
static PyObject*
« no previous file with comments | « Lib/test/test_sys.py ('k') | Objects/memoryobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+