mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-22 22:03:40 +00:00
added hashlib::mkhash_init
This commit is contained in:
parent
ba43cf5807
commit
0675098733
4 changed files with 8 additions and 5 deletions
|
@ -21,13 +21,15 @@ const int hashtable_size_trigger = 2;
|
|||
const int hashtable_size_factor = 3;
|
||||
|
||||
// The XOR version of DJB2
|
||||
// (traditionally 5381 is used as starting value for the djb2 hash)
|
||||
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;
|
||||
|
||||
// The ADD version of DJB2
|
||||
// (use this version for cache locality in b)
|
||||
// (usunsigned int mkhashe this version for cache locality in b)
|
||||
inline unsigned int mkhash_add(unsigned int a, unsigned int b) {
|
||||
return ((a << 5) + a) + b;
|
||||
}
|
||||
|
@ -96,7 +98,7 @@ struct hash_cstr_ops {
|
|||
return true;
|
||||
}
|
||||
unsigned int hash(const char *a) const {
|
||||
unsigned int hash = 5381;
|
||||
unsigned int hash = mkhash_init;
|
||||
while (*a)
|
||||
hash = mkhash(hash, *(a++));
|
||||
return hash;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue