diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2021-11-05 18:12:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-05 18:12:40 +0000 |
| commit | ee259e42298eca0e4e5d6b8681c2403c3bf7a80e (patch) | |
| tree | 7bfd15490ddc4be6fcd41b4f969df6c901d98f76 /src/common.cpp | |
| parent | e963fc4d6a2b8fc63f46bb57b2c727999ce39e29 (diff) | |
| parent | 36985f8da0cea59cb1912f62ae4e700983159b6a (diff) | |
Merge pull request #1273 from odin-lang/compiler-map-improvements
Compiler Map Improvements
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/common.cpp b/src/common.cpp index 7af7026b9..cca478421 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -275,9 +275,9 @@ gb_global String global_module_path = {0}; gb_global bool global_module_path_set = false; -#include "string_map.cpp" -#include "map.cpp" +#include "ptr_map.cpp" #include "ptr_set.cpp" +#include "string_map.cpp" #include "string_set.cpp" #include "priority_queue.cpp" #include "thread_pool.cpp" @@ -289,13 +289,13 @@ struct StringIntern { char str[1]; }; -Map<StringIntern *> string_intern_map = {}; // Key: u64 +PtrMap<uintptr, StringIntern *> string_intern_map = {}; // Key: u64 gb_global Arena string_intern_arena = {}; char const *string_intern(char const *text, isize len) { u64 hash = gb_fnv64a(text, len); - u64 key = hash ? hash : 1; - StringIntern **found = map_get(&string_intern_map, hash_integer(key)); + uintptr key = cast(uintptr)(hash ? hash : 1); + StringIntern **found = map_get(&string_intern_map, key); if (found) { for (StringIntern *it = *found; it != nullptr; it = it->next) { if (it->len == len && gb_strncmp(it->str, (char *)text, len) == 0) { @@ -309,7 +309,7 @@ char const *string_intern(char const *text, isize len) { new_intern->next = found ? *found : nullptr; gb_memmove(new_intern->str, text, len); new_intern->str[len] = 0; - map_set(&string_intern_map, hash_integer(key), new_intern); + map_set(&string_intern_map, key, new_intern); return new_intern->str; } |