mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 16:28:19 +02:00
Use XXHash for hash table hashing of arbitrary sized keys
Much faster than FNV
This commit is contained in:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user