Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/mathutils/mathutils.c
| Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | Py_hash_t mathutils_array_hash(const float *array, size_t array_len) | ||||
| Py_uhash_t mult; | Py_uhash_t mult; | ||||
| Py_ssize_t len; | Py_ssize_t len; | ||||
| mult = _PyHASH_MULTIPLIER; | mult = _PyHASH_MULTIPLIER; | ||||
| len = array_len; | len = array_len; | ||||
| x = 0x345678UL; | x = 0x345678UL; | ||||
| i = 0; | i = 0; | ||||
| while (--len >= 0) { | while (--len >= 0) { | ||||
| #if PY_VERSION_HEX < 0x030a0000 | |||||
| y = _Py_HashDouble((double)(array[i++])); | |||||
| #else | |||||
| y = _Py_HashDouble(NULL, (double)(array[i++])); | y = _Py_HashDouble(NULL, (double)(array[i++])); | ||||
| #endif | |||||
| if (y == -1) { | if (y == -1) { | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| x = (x ^ y) * mult; | x = (x ^ y) * mult; | ||||
| /* the cast might truncate len; that doesn't change hash stability */ | /* the cast might truncate len; that doesn't change hash stability */ | ||||
| mult += (Py_hash_t)(82520UL + len + len); | mult += (Py_hash_t)(82520UL + len + len); | ||||
| } | } | ||||
| x += 97531UL; | x += 97531UL; | ||||
| ▲ Show 20 Lines • Show All 722 Lines • Show Last 20 Lines | |||||