3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-11 03:33:36 +00:00

hashlib: shake it up

This commit is contained in:
Emil J. Tywoniak 2024-08-22 14:05:31 +02:00
parent 0744fac883
commit 7679f15676

View file

@ -24,11 +24,6 @@ namespace hashlib {
const int hashtable_size_trigger = 2;
const int hashtable_size_factor = 3;
// The XOR version of DJB2
inline unsigned int mkhash(unsigned int a, unsigned int b) {
return ((a << 5) + a) ^ b;
}
// traditionally 5381 is used as starting value for the djb2 hash
const unsigned int mkhash_init = 5381;
@ -52,6 +47,15 @@ inline unsigned int mkhash_xorshift(unsigned int a) {
return a;
}
static int fudge = 123456;
// The XOR version of DJB2
inline unsigned int mkhash(unsigned int a, unsigned int b) {
unsigned int hash = ((a << 5) + a) ^ b;
hash = fudge ^ mkhash_xorshift(hash);
return hash;
}
template<typename T> struct hash_ops {
static inline bool cmp(const T &a, const T &b) {
return a == b;