mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
Update namedict.c
This commit is contained in:
parent
39106e272b
commit
7135e1ce59
@ -5,7 +5,20 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define HASH_KEY(__k) ((uintptr_t)(__k) >> 3U)
|
// https://jfdube.wordpress.com/2011/10/12/hashing-strings-and-pointers-avoiding-common-pitfalls/
|
||||||
|
uintptr_t ThomasWangInt32Hash(void* Ptr) {
|
||||||
|
// Here we think only the lower 32 bits are useful
|
||||||
|
uint32_t Value = (uint32_t)(uintptr_t)Ptr;
|
||||||
|
Value = ~Value + (Value << 15);
|
||||||
|
Value = Value ^ (Value >> 12);
|
||||||
|
Value = Value + (Value << 2);
|
||||||
|
Value = Value ^ (Value >> 4);
|
||||||
|
Value = Value * 2057;
|
||||||
|
Value = Value ^ (Value >> 16);
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HASH_KEY(__k) ThomasWangInt32Hash(__k)
|
||||||
|
|
||||||
#define HASH_PROBE_0(__k, ok, i) \
|
#define HASH_PROBE_0(__k, ok, i) \
|
||||||
ok = false; \
|
ok = false; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user