diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-12-17 14:28:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-17 14:28:15 +0100 |
commit | ad3393743c2e505f68a12b20113f9c2bda88fa89 (patch) | |
tree | 788e795e1465e2458d58372a0868c419eb1d2568 /core | |
parent | 539fd14cf5940896c90eeb141e9bfee3b31c3ca9 (diff) | |
parent | 9ba134b46381e0d2e65eb548384626da20bf09a3 (diff) |
Merge pull request #14760 from hpvb/add-several-unlikely-macros
Add several unlikely() macros
Diffstat (limited to 'core')
-rw-r--r-- | core/hash_map.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/core/hash_map.h b/core/hash_map.h index a53cb53c84..3ec3961d73 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -313,7 +313,7 @@ public: _FORCE_INLINE_ TData *getptr(const TKey &p_key) { - if (!hash_table) + if (unlikely(!hash_table)) return NULL; Element *e = const_cast<Element *>(get_element(p_key)); @@ -326,7 +326,7 @@ public: _FORCE_INLINE_ const TData *getptr(const TKey &p_key) const { - if (!hash_table) + if (unlikely(!hash_table)) return NULL; const Element *e = const_cast<Element *>(get_element(p_key)); @@ -345,7 +345,7 @@ public: template <class C> _FORCE_INLINE_ TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) { - if (!hash_table) + if (unlikely(!hash_table)) return NULL; uint32_t hash = p_custom_hash; @@ -371,7 +371,7 @@ public: template <class C> _FORCE_INLINE_ const TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) const { - if (!hash_table) + if (unlikely(!hash_table)) return NULL; uint32_t hash = p_custom_hash; @@ -400,7 +400,7 @@ public: bool erase(const TKey &p_key) { - if (!hash_table) + if (unlikely(!hash_table)) return false; uint32_t hash = Hasher::hash(p_key); @@ -478,7 +478,8 @@ public: */ const TKey *next(const TKey *p_key) const { - if (!hash_table) return NULL; + if (unlikely(!hash_table)) + return NULL; if (!p_key) { /* get the first key */ @@ -559,7 +560,7 @@ public: } void get_key_value_ptr_array(const Pair **p_pairs) const { - if (!hash_table) + if (unlikely(!hash_table)) return; for (int i = 0; i < (1 << hash_table_power); i++) { @@ -573,7 +574,7 @@ public: } void get_key_list(List<TKey> *p_keys) const { - if (!hash_table) + if (unlikely(!hash_table)) return; for (int i = 0; i < (1 << hash_table_power); i++) { |