Use XXHash for hash table hashing of arbitrary sized keys

Much faster than FNV
This commit is contained in:
Kovid Goyal
2024-12-16 20:53:36 +05:30
parent b602915d5b
commit dc1bed1bd1
2 changed files with 14 additions and 9 deletions

View File

@@ -7,16 +7,12 @@
#include "../3rdparty/verstable.h"
#include <stdint.h>
#include <xxhash.h>
#ifndef __kitty_verstable_extra_hash_functions__
#define __kitty_verstable_extra_hash_functions__
// FNV-1a (matches vt_hash_string)
static inline uint64_t
vt_hash_bytes(const void *data, const size_t size) {
uint64_t hash = 0xcbf29ce484222325ull;
for (size_t i = 0; i < size; i++) hash = ( (uint64_t)(((unsigned char*)data)[i] ^ hash )) * 0x100000001b3ull;
return hash;
}
#define vt_hash_bytes XXH3_64bits
static inline uint64_t vt_hash_float(float x) { return vt_hash_integer((uint64_t)x); }
static inline bool vt_cmpr_float(float a, float b) { return a == b; }