Skip to content

Commit

Permalink
Switch int64to32hash and MIX to use FxHasher
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Dec 18, 2023
1 parent 80ee622 commit 841185a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/flisp/equal.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,10 @@ value_t fl_equal(fl_context_t *fl_ctx, value_t a, value_t b)
* less redundant tag checking, 3-bit tags
*/

#define MIX(a, b) bitmix(a, b)
#ifdef _P64
#define MIX(a, b) int64hash((int64_t)(a) ^ (int64_t)(b));
#define doublehash(a) int64hash(a)
#else
#define MIX(a, b) int64to32hash(((int64_t)(a))<<32 | ((int64_t)(b)))
#define doublehash(a) int64to32hash(a)
#endif

Expand Down
13 changes: 5 additions & 8 deletions src/support/hashing.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@
extern "C" {
#endif

// FxHasher
uint32_t int32hash(uint32_t a)
{
return a * 0x9e3779b9;
}

// FxHasher
uint64_t int64hash(uint64_t key)
{
return key * 0x517cc1b727220a95;
}

uint32_t int64to32hash(uint64_t key)
{
key = (~key) + (key << 18); // key = (key << 18) - key - 1;
key = key ^ (key >> 31);
key = key * 21; // key = (key + (key << 2)) + (key << 4);
key = key ^ (key >> 11);
key = key + (key << 6);
key = key ^ (key >> 22);
return (uint32_t)key;
uint32_t h = 0;
h = bitmix(h, (uint32_t)key);
h = bitmix(h, (uint32_t)(key >> 32));
return h;
}

#include "MurmurHash3.c"
Expand Down

0 comments on commit 841185a

Please sign in to comment.