Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break tests with a small hash function perturbation #4559

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions kernel/hashlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
Loading