diff options
| author | gingerBill <bill@gingerbill.org> | 2021-11-05 17:13:07 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-11-05 17:13:07 +0000 |
| commit | 541beb615b745b45f2cc82813014a3e04f1a3231 (patch) | |
| tree | ea3e2998ecd095ed3e8b49da7eefb25e36f350fe /src/common.cpp | |
| parent | 6646348e1a0086d9a2341d0866f787ffc2608c8f (diff) | |
Move more things to `PtrMap`
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common.cpp b/src/common.cpp index 5d7c87b6d..f7a0653ac 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -290,13 +290,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) { @@ -310,7 +310,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; } |