summaryrefslogtreecommitdiff
path: root/core/hash_map.h
diff options
context:
space:
mode:
authorqarmin <mikrutrafal54@gmail.com>2019-07-01 12:59:42 +0200
committerqarmin <mikrutrafal54@gmail.com>2019-07-01 12:59:42 +0200
commit3c154eb93b3a098354bf6d18a9428826ec193f90 (patch)
treed9c8c44f13883ceadaefc95953f9cb077137b7c8 /core/hash_map.h
parenteaaff9da3178fa515a0f051fda932c1dd04d53db (diff)
Remove unnecessary code and add some error explanations
Diffstat (limited to 'core/hash_map.h')
-rw-r--r--core/hash_map.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/hash_map.h b/core/hash_map.h
index 31332991de..1513d7a65b 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -208,7 +208,10 @@ private:
/* if element doesn't exist, create it */
Element *e = memnew(Element);
- ERR_FAIL_COND_V(!e, NULL); /* out of memory */
+ if (!e) {
+ ERR_EXPLAIN("Out of memory");
+ ERR_FAIL_V(NULL);
+ }
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
e->next = hash_table[index];
@@ -495,8 +498,10 @@ public:
} else { /* get the next key */
const Element *e = get_element(*p_key);
- ERR_FAIL_COND_V(!e, NULL); /* invalid key supplied */
-
+ if (!e) {
+ ERR_EXPLAIN("Invalid key supplied")
+ ERR_FAIL_V(NULL);
+ }
if (e->next) {
/* if there is a "next" in the list, return that */
return &e->next->pair.key;