aboutsummaryrefslogtreecommitdiff
path: root/src/exact_value.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2021-11-05 18:12:40 +0000
committerGitHub <noreply@github.com>2021-11-05 18:12:40 +0000
commitee259e42298eca0e4e5d6b8681c2403c3bf7a80e (patch)
tree7bfd15490ddc4be6fcd41b4f969df6c901d98f76 /src/exact_value.cpp
parente963fc4d6a2b8fc63f46bb57b2c727999ce39e29 (diff)
parent36985f8da0cea59cb1912f62ae4e700983159b6a (diff)
Merge pull request #1273 from odin-lang/compiler-map-improvements
Compiler Map Improvements
Diffstat (limited to 'src/exact_value.cpp')
-rw-r--r--src/exact_value.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/exact_value.cpp b/src/exact_value.cpp
index 363c6d863..fd90278e5 100644
--- a/src/exact_value.cpp
+++ b/src/exact_value.cpp
@@ -63,44 +63,39 @@ struct ExactValue {
gb_global ExactValue const empty_exact_value = {};
-HashKey hash_exact_value(ExactValue v) {
+uintptr hash_exact_value(ExactValue v) {
mutex_lock(&hash_exact_value_mutex);
defer (mutex_unlock(&hash_exact_value_mutex));
- HashKey empty = {};
switch (v.kind) {
case ExactValue_Invalid:
- return empty;
+ return 0;
case ExactValue_Bool:
- return hash_integer(u64(v.value_bool));
+ return gb_fnv32a(&v.value_bool, gb_size_of(v.value_bool));
case ExactValue_String:
- {
- char const *str = string_intern(v.value_string);
- return hash_pointer(str);
- }
+ return ptr_map_hash_key(string_intern(v.value_string));
case ExactValue_Integer:
{
- HashKey key = hashing_proc(v.value_integer.dp, gb_size_of(*v.value_integer.dp) * v.value_integer.used);
+ u32 key = gb_fnv32a(v.value_integer.dp, gb_size_of(*v.value_integer.dp) * v.value_integer.used);
u8 last = (u8)v.value_integer.sign;
- key.key = (key.key ^ last) * 0x100000001b3ll;
- return key;
+ return (key ^ last) * 0x01000193;
}
case ExactValue_Float:
- return hash_f64(v.value_float);
+ return gb_fnv32a(&v.value_float, gb_size_of(v.value_float));
case ExactValue_Pointer:
- return hash_integer(v.value_pointer);
+ return ptr_map_hash_key(v.value_pointer);
case ExactValue_Complex:
- return hashing_proc(v.value_complex, gb_size_of(Complex128));
+ return gb_fnv32a(v.value_complex, gb_size_of(Complex128));
case ExactValue_Quaternion:
- return hashing_proc(v.value_quaternion, gb_size_of(Quaternion256));
+ return gb_fnv32a(v.value_quaternion, gb_size_of(Quaternion256));
case ExactValue_Compound:
- return hash_pointer(v.value_compound);
+ return ptr_map_hash_key(v.value_compound);
case ExactValue_Procedure:
- return hash_pointer(v.value_procedure);
+ return ptr_map_hash_key(v.value_procedure);
case ExactValue_Typeid:
- return hash_pointer(v.value_typeid);
+ return ptr_map_hash_key(v.value_typeid);
}
- return hashing_proc(&v, gb_size_of(ExactValue));
+ return gb_fnv32a(&v, gb_size_of(ExactValue));
}