We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
_combine_hashes
1 parent 745b3b9 commit 22f55bbCopy full SHA for 22f55bb
1 file changed
Objects/dictobject.c
@@ -8222,17 +8222,23 @@ frozendict_repr(PyObject *self)
8222
return res;
8223
}
8224
8225
-// based on boost's old hash_combine
8226
static inline Py_uhash_t
8227
_combine_hashes(Py_uhash_t h1, Py_uhash_t h2)
8228
{
8229
- // 2^sizeof(Py_hash_t) / phi
8230
#if SIZEOF_PY_HASH_T == 8
+ // 2^sizeof(Py_hash_t) / phi
8231
const Py_uhash_t GOLDEN_C = 0x9e3779b97f4a7c15ULL;
+ h1 += GOLDEN_C;
8232
+ h1 ^= h2;
8233
+ h1 ^= (h1 << 13) + (h1 >> 3);
8234
+ h1 ^= h1 >> 33;
8235
#else
8236
const Py_uhash_t GOLDEN_C = 0x9e3779b9UL;
8237
8238
8239
+ h1 ^= (h1 << 6) + (h1 >> 2);
8240
+ h1 ^= h1 >> 16;
8241
#endif
- h1 ^= h2 + GOLDEN_C + (h1 << 6) + (h1 >> 2);
8242
return h1;
8243
8244
0 commit comments