diff options
Diffstat (limited to 'kernel/hashmap.h')
-rw-r--r-- | kernel/hashmap.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/hashmap.h b/kernel/hashmap.h index 729b4916c..431e8122e 100644 --- a/kernel/hashmap.h +++ b/kernel/hashmap.h @@ -25,10 +25,18 @@ #define YOSYS_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; } +// The ADD version of DJB2 +// (use this version as last call for cache locality in b) +inline unsigned int mkhash_add(unsigned int a, unsigned int b) { + return ((a << 5) + a) + b; +} + template<typename T> struct hash_ops { bool cmp(const T &a, const T &b) const { return a == b; |