mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-26 06:07:03 +00:00
hashlib: shake it up
This commit is contained in:
parent
0744fac883
commit
7679f15676
1 changed files with 9 additions and 5 deletions
|
@ -24,11 +24,6 @@ namespace hashlib {
|
||||||
const int hashtable_size_trigger = 2;
|
const int hashtable_size_trigger = 2;
|
||||||
const int hashtable_size_factor = 3;
|
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
|
// traditionally 5381 is used as starting value for the djb2 hash
|
||||||
const unsigned int mkhash_init = 5381;
|
const unsigned int mkhash_init = 5381;
|
||||||
|
|
||||||
|
@ -52,6 +47,15 @@ inline unsigned int mkhash_xorshift(unsigned int a) {
|
||||||
return 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 {
|
template<typename T> struct hash_ops {
|
||||||
static inline bool cmp(const T &a, const T &b) {
|
static inline bool cmp(const T &a, const T &b) {
|
||||||
return a == b;
|
return a == b;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue