mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214) (#119334)
gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214)
(cherry picked from commit f6da790122
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
6be55f1bed
commit
1177897551
7 changed files with 16 additions and 7 deletions
|
@ -263,12 +263,12 @@ fnv(const void *src, Py_ssize_t len)
|
|||
x ^= (Py_uhash_t) *p << 7;
|
||||
while (blocks--) {
|
||||
PY_UHASH_CPY(block.bytes, p);
|
||||
x = (_PyHASH_MULTIPLIER * x) ^ block.value;
|
||||
x = (PyHASH_MULTIPLIER * x) ^ block.value;
|
||||
p += SIZEOF_PY_UHASH_T;
|
||||
}
|
||||
/* add remainder */
|
||||
for (; remainder > 0; remainder--)
|
||||
x = (_PyHASH_MULTIPLIER * x) ^ (Py_uhash_t) *p++;
|
||||
x = (PyHASH_MULTIPLIER * x) ^ (Py_uhash_t) *p++;
|
||||
x ^= (Py_uhash_t) len;
|
||||
x ^= (Py_uhash_t) _Py_HashSecret.fnv.suffix;
|
||||
if (x == (Py_uhash_t) -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue