diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-10 15:15:10 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-10 15:15:10 +0100 |
| commit | 484d5df5dfda42cf03bb1f67f310b06d98a803af (patch) | |
| tree | bbfae22d5d545f2d7c04fc722fb8b7e9be77052a /src/string_map.cpp | |
| parent | 3a840d239a49072173b50706ed1595d0fc83c708 (diff) | |
| parent | 9f7154a03941f1ffad629e8e558040911e9886ba (diff) | |
Merge branch 'master' into llvm-12-support
Diffstat (limited to 'src/string_map.cpp')
| -rw-r--r-- | src/string_map.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/string_map.cpp b/src/string_map.cpp index 7a446937a..09e125800 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -54,6 +54,10 @@ template <typename T> T * string_map_get (StringMap<T> *h, char co template <typename T> T * string_map_get (StringMap<T> *h, String const &key); template <typename T> T * string_map_get (StringMap<T> *h, StringHashKey const &key); +template <typename T> T & string_map_must_get (StringMap<T> *h, char const *key); +template <typename T> T & string_map_must_get (StringMap<T> *h, String const &key); +template <typename T> T & string_map_must_get (StringMap<T> *h, StringHashKey const &key); + template <typename T> void string_map_set (StringMap<T> *h, StringHashKey const &key, T const &value); template <typename T> void string_map_set (StringMap<T> *h, String const &key, T const &value); template <typename T> void string_map_set (StringMap<T> *h, char const *key, T const &value); @@ -188,6 +192,23 @@ gb_inline T *string_map_get(StringMap<T> *h, char const *key) { } template <typename T> +T &string_map_must_get(StringMap<T> *h, StringHashKey const &key) { + isize index = string_map__find(h, key).entry_index; + GB_ASSERT(index >= 0); + return h->entries[index].value; +} + +template <typename T> +gb_inline T &string_map_must_get(StringMap<T> *h, String const &key) { + return string_map_must_get(h, string_hash_string(key)); +} + +template <typename T> +gb_inline T &string_map_must_get(StringMap<T> *h, char const *key) { + return string_map_must_get(h, string_hash_string(make_string_c(key))); +} + +template <typename T> void string_map_set(StringMap<T> *h, StringHashKey const &key, T const &value) { isize index; StringMapFindResult fr; |