General improves to alloc_ast_node and other unnecessary checks

This commit is contained in:
gingerBill
2023-01-03 14:45:09 +00:00
parent 69934c3b0b
commit 0fb3032b73
8 changed files with 16 additions and 16 deletions

View File

@@ -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);