| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,7 +145,7 @@ Used in: PY_LONG_LONG | |||
| 145 | 145 | #endif | |
| 146 | 146 | ||
| 147 | 147 | /* Prime multiplier used in string and various other hashes. */ | |
| 148 | - #define _PyHASH_MULTIPLIER 1000003 /* 0xf4243 */ | ||
| 148 | + #define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */ | ||
| 149 | 149 | ||
| 150 | 150 | /* Parameters used for the numeric hash implementation. See notes for | |
| 151 | 151 | _Py_HashDouble in Objects/object.c. Numeric hashes are based on | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,7 +77,7 @@ NULL if the rich comparison returns an error. | |||
| 77 | 77 | static setentry * | |
| 78 | 78 | set_lookkey(PySetObject *so, PyObject *key, register Py_hash_t hash) | |
| 79 | 79 | { | |
| 80 | - register size_t i; | ||
| 80 | + register size_t i; /* Unsigned for defined overflow behavior. */ | ||
| 81 | 81 | register size_t perturb; | |
| 82 | 82 | register setentry *freeslot; | |
| 83 | 83 | register size_t mask = so->mask; | |
@@ -159,7 +159,7 @@ set_lookkey(PySetObject *so, PyObject *key, register Py_hash_t hash) | |||
| 159 | 159 | static setentry * | |
| 160 | 160 | set_lookkey_unicode(PySetObject *so, PyObject *key, register Py_hash_t hash) | |
| 161 | 161 | { | |
| 162 | - register size_t i; | ||
| 162 | + register size_t i; /* Unsigned for defined overflow behavior. */ | ||
| 163 | 163 | register size_t perturb; | |
| 164 | 164 | register setentry *freeslot; | |
| 165 | 165 | register size_t mask = so->mask; | |
@@ -760,7 +760,7 @@ static Py_hash_t | |||
| 760 | 760 | frozenset_hash(PyObject *self) | |
| 761 | 761 | { | |
| 762 | 762 | PySetObject *so = (PySetObject *)self; | |
| 763 | - Py_uhash_t h, hash = 1927868237U; | ||
| 763 | + Py_uhash_t h, hash = 1927868237UL; | ||
| 764 | 764 | setentry *entry; | |
| 765 | 765 | Py_ssize_t pos = 0; | |
| 766 | 766 | ||
@@ -775,11 +775,11 @@ frozenset_hash(PyObject *self) | |||
| 775 | 775 | hashes so that many distinct combinations collapse to only | |
| 776 | 776 | a handful of distinct hash values. */ | |
| 777 | 777 | h = entry->hash; | |
| 778 | - hash ^= (h ^ (h << 16) ^ 89869747U) * 3644798167U; | ||
| 778 | + hash ^= (h ^ (h << 16) ^ 89869747UL) * 3644798167UL; | ||
| 779 | 779 | } | |
| 780 | - hash = hash * 69069U + 907133923U; | ||
| 780 | + hash = hash * 69069U + 907133923UL; | ||
| 781 | 781 | if (hash == -1) | |
| 782 | - hash = 590923713U; | ||
| 782 | + hash = 590923713UL; | ||
| 783 | 783 | so->hash = hash; | |
| 784 | 784 | return hash; | |
| 785 | 785 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -327,22 +327,22 @@ tuplerepr(PyTupleObject *v) | |||
| 327 | 327 | static Py_hash_t | |
| 328 | 328 | tuplehash(PyTupleObject *v) | |
| 329 | 329 | { | |
| 330 | - register Py_uhash_t x; | ||
| 330 | + register Py_uhash_t x; /* Unsigned for defined overflow behavior. */ | ||
| 331 | 331 | register Py_hash_t y; | |
| 332 | 332 | register Py_ssize_t len = Py_SIZE(v); | |
| 333 | 333 | register PyObject **p; | |
| 334 | 334 | Py_uhash_t mult = _PyHASH_MULTIPLIER; | |
| 335 | - x = 0x345678; | ||
| 335 | + x = 0x345678UL; | ||
| 336 | 336 | p = v->ob_item; | |
| 337 | 337 | while (--len >= 0) { | |
| 338 | 338 | y = PyObject_Hash(*p++); | |
| 339 | 339 | if (y == -1) | |
| 340 | 340 | return -1; | |
| 341 | 341 | x = (x ^ y) * mult; | |
| 342 | 342 | /* the cast might truncate len; that doesn't change hash stability */ | |
| 343 | - mult += (Py_hash_t)(82520L + len + len); | ||
| 343 | + mult += (Py_hash_t)(82520UL + len + len); | ||
| 344 | 344 | } | |
| 345 | - x += 97531L; | ||
| 345 | + x += 97531UL; | ||
| 346 | 346 | if (x == (Py_uhash_t)-1) | |
| 347 | 347 | x = -2; | |
| 348 | 348 | return x; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11008,7 +11008,7 @@ static Py_hash_t | |||
| 11008 | 11008 | unicode_hash(PyObject *self) | |
| 11009 | 11009 | { | |
| 11010 | 11010 | Py_ssize_t len; | |
| 11011 | - Py_uhash_t x; | ||
| 11011 | + Py_uhash_t x; /* Unsigned for defined overflow behavior. */ | ||
| 11012 | 11012 | ||
| 11013 | 11013 | #ifdef Py_DEBUG | |
| 11014 | 11014 | assert(_Py_HashSecret_Initialized); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments