diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-12-30 18:51:24 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-12-30 18:51:24 +0100 |
commit | 06750987331a3d832ea83f2205c56612d3506332 (patch) | |
tree | 7f4593afb250d49c403f9f56e135918292686526 /kernel/hashlib.h | |
parent | ba43cf5807dadac970ff10afed4963d1ee329217 (diff) | |
download | yosys-06750987331a3d832ea83f2205c56612d3506332.tar.gz yosys-06750987331a3d832ea83f2205c56612d3506332.tar.bz2 yosys-06750987331a3d832ea83f2205c56612d3506332.zip |
added hashlib::mkhash_init
Diffstat (limited to 'kernel/hashlib.h')
-rw-r--r-- | kernel/hashlib.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h index c93e00a09..0b6e94a32 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -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; |