4 * Hashing for Lempel-Ziv matchfinding.
9 * The author dedicates this file to the public domain.
10 * You can do whatever you want with this file.
16 #include "wimlib/types.h"
19 * The hash function: given a sequence prefix held in the low-order bits of a
20 * 32-bit value, multiply by a carefully-chosen large constant. Discard any
21 * bits of the product that don't fit in a 32-bit value, but take the
22 * next-highest @num_bits bits of the product as the hash value, as those have
23 * the most randomness.
26 lz_hash(u32 seq, unsigned num_bits)
28 return (u32)(seq * 0x1E35A7BD) >> (32 - num_bits);
31 #endif /* _LZ_HASH_H */