diff options
author | Dmitriy Nester <[email protected]> | 2020-02-27 15:17:45 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-25 19:41:09 +0000 |
commit | 387176829bcef7058ff2be8f175295e9f80008e5 (patch) | |
tree | 5f82936ee30d0d5e67e921827dee5249cb2de032 /src/util | |
parent | 013df5849897e71f62a0df12691f19f0d56cbdf3 (diff) |
util/hash_table: replace fnv1a hash function with xxhash
xxhash is faster than fnv1a in almost all circumstances, so we're
switching to it globally.
Signed-off-by: Dmytro Nester <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4020>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/hash_table.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/util/hash_table.c b/src/util/hash_table.c index 0b0077cc7f3..7b2b7eb0d6a 100644 --- a/src/util/hash_table.c +++ b/src/util/hash_table.c @@ -597,14 +597,14 @@ _mesa_hash_u32(const void *key) uint32_t _mesa_hash_string(const void *_key) { - uint32_t hash = _mesa_fnv32_1a_offset_bias; + uint32_t hash = 0; const char *key = _key; - - while (*key != 0) { - hash = _mesa_fnv32_1a_accumulate(hash, *key); - key++; - } - + size_t len = strlen(key); +#if defined(_WIN64) || defined(__x86_64__) + hash = (uint32_t)XXH64(key, len, hash); +#else + hash = XXH32(key, len, hash); +#endif return hash; } |