History

ptrhash: use a simple hash function (taken from Julia)

Sigrid Solveig Haflínudóttir committed 4 months ago

Commit 1c8976d1 parent b7cbfee1 file · +2 −18Browse files

Unified · Split

src/ptrhash.c+2−18
@@ -5,26 +5,10 @@ · 4 unmodified lines
55
66 #include "slpriv.h"
77
8−static sl_v
8+static inline sl_v
99 ptrhash(sl_v a)
1010 {
11−#if defined(BITS64)
12− a = (~a) + (a << 21); // a = (a << 21) - a - 1;
13− a = a ^ (a >> 24);
14− a = (a + (a << 3)) + (a << 8); // a * 265
15− a = a ^ (a >> 14);
16− a = (a + (a << 2)) + (a << 4); // a * 21
17− a = a ^ (a >> 28);
18− a = a + (a << 31);
19−#else
20− a = (a+0x7ed55d16) + (a<<12);
21− a = (a^0xc761c23c) ^ (a>>19);
22− a = (a+0x165667b1) + (a<<5);
23− a = (a+0xd3a2646c) ^ (a<<9);
24− a = (a+0xfd7046c5) + (a<<3);
25− a = (a^0xb55a4f09) ^ (a>>16);
26−#endif
27− return a;
11+ return (a >> 4) ^ (a >> 9);
2812 }
2913
3014 #define HTNAME(suffix) ptrhash##suffix

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t