X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=hash.h;h=39f01e08109712450c6381bab7772b43f140b0a8;hb=04d675c5a4a867b2c15e2ef64d5179353fd1489e;hp=9b9550afec5574228e9b4a5dd3b82013ddd2b72d;hpb=2a322a4ad576d87535ce8a479f7a516da9457e80;p=remoteglot-book diff --git a/hash.h b/hash.h index 9b9550a..39f01e0 100644 --- a/hash.h +++ b/hash.h @@ -1,6 +1,12 @@ #ifndef _HASH_H #define _HASH_H 1 +// Hashing more or fewer bytes is a tradeoff between more even partitions +// and total size (since seemingly key/prefix compression works better with +// smaller values). This value seems to be very close to optimal wrt. size, +// and has imbalances smaller than 2:1. +#define HASH_PREFIX_BYTES 4 + int hash_key_to_bucket(const char* s, size_t len, int num_buckets); #endif // !defined(_HASH_H)