diff options
author | Michael Forney <mforney@mforney.org> | 2024-03-29 17:25:56 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-04-02 14:06:59 -0700 |
commit | fef86b0202a3d4ef191926fee683eb92e9218bd4 (patch) | |
tree | 0fe65e7c022ed3bd0b3a62fd8bed6d84c27ffb17 /map.c | |
parent | 8120240c1f17cf536228b79144d41168a48a4fcc (diff) |
map: Use simpler fnv-1a hash function
Diffstat (limited to 'map.c')
-rw-r--r-- | map.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1,20 +1,20 @@ #include <assert.h> #include <stdbool.h> -#include <stdint.h> #include <stdlib.h> #include <string.h> #include "util.h" -static uint64_t +static unsigned long hash(const void *ptr, size_t len) { - extern int siphash(const uint8_t *, const size_t, const uint8_t *, uint8_t *, const size_t); - static const uint8_t k[16] = {0}; /* XXX: we don't have a way to get entropy in standard C */ - uint64_t r; - - siphash(ptr, len, k, (uint8_t *)&r, sizeof(r)); - - return r; + unsigned long h; + const unsigned char *pos, *end; + + /* FNV-1a */ + h = 0x811c9dc5; + for (pos = ptr, end = pos + len; pos != end; ++pos) + h = (h ^ *pos) * 0x1000193; + return h; } void |