Skip to content

Commit

Permalink
hash: add hash_fast_murmur()
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Feb 1, 2023
1 parent 059b9d5 commit df1eb59
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/re_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ uint32_t hash_joaat_pl(const struct pl *pl);
uint32_t hash_joaat_pl_ci(const struct pl *pl);
uint32_t hash_fast(const char *k, size_t len);
uint32_t hash_fast_str(const char *str);
uint32_t hash_fast_murmur(uint32_t key);
19 changes: 19 additions & 0 deletions src/hash/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,22 @@ uint32_t hash_fast_str(const char *str)

return h;
}


/**
* Calculate hash-value using modified murmur (fast finalize part)
*
* @param key Key value
*
* @return Calculated hash-value
*/
uint32_t hash_fast_murmur(uint32_t key)
{
key ^= key >> 16;
key *= 0x85ebca6b;
key ^= key >> 13;
key *= 0xc2b2ae35;
key ^= key >> 16;

return key;
}

0 comments on commit df1eb59

Please sign in to comment.