aboutsummaryrefslogtreecommitdiff
path: root/src/ptr_map.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-03 14:45:09 +0000
committergingerBill <bill@gingerbill.org>2023-01-03 14:45:09 +0000
commit0fb3032b731b640a2d0d1d62b9f8dd548e224b0e (patch)
tree178b8cc6c72684d7f0b0041af2b5616804b31638 /src/ptr_map.cpp
parent69934c3b0b1b8ad0a499574c39c1ab177a1fe30a (diff)
General improves to `alloc_ast_node` and other unnecessary checks
Diffstat (limited to 'src/ptr_map.cpp')
-rw-r--r--src/ptr_map.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ptr_map.cpp b/src/ptr_map.cpp
index 083cd6697..264136881 100644
--- a/src/ptr_map.cpp
+++ b/src/ptr_map.cpp
@@ -27,6 +27,7 @@ struct PtrMap {
gb_internal gb_inline u32 ptr_map_hash_key(uintptr key) {
+ u32 res;
#if defined(GB_ARCH_64_BIT)
key = (~key) + (key << 21);
key = key ^ (key >> 24);
@@ -34,12 +35,13 @@ gb_internal gb_inline u32 ptr_map_hash_key(uintptr key) {
key = key ^ (key >> 14);
key = (key + (key << 2)) + (key << 4);
key = key ^ (key << 28);
- return cast(u32)key;
+ res = cast(u32)key;
#elif defined(GB_ARCH_32_BIT)
u32 state = ((u32)key) * 747796405u + 2891336453u;
u32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
- return (word >> 22u) ^ word;
+ res = (word >> 22u) ^ word;
#endif
+ return res ^ (res == MAP_SENTINEL);
}
gb_internal gb_inline u32 ptr_map_hash_key(void const *key) {
return ptr_map_hash_key((uintptr)key);