diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-26 18:31:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 18:31:17 +0200 |
commit | 2116ecc46a53c32797e9f95dbbb973dc4a975bc9 (patch) | |
tree | 70f69dc01da9b04548fb6457f5d957806e048138 | |
parent | 5c54770b7cd0be8ed6e9229fd253ae0d98f8b275 (diff) | |
parent | 40663494881fd4eb6e819e5ec40a55f110090de1 (diff) |
Merge pull request #60420 from AndreaCatania/fix_looup_ptr_const
Add mutable OAHashMap::lookup_ptr function to fix mutability.
-rw-r--r-- | core/templates/oa_hash_map.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/core/templates/oa_hash_map.h b/core/templates/oa_hash_map.h index e4d9323c45..25c21d1802 100644 --- a/core/templates/oa_hash_map.h +++ b/core/templates/oa_hash_map.h @@ -246,13 +246,17 @@ public: return false; } - /** - * returns true if the value was found, false otherwise. - * - * if r_data is not nullptr then the value will be written to the object - * it points to. - */ - TValue *lookup_ptr(const TKey &p_key) const { + const TValue *lookup_ptr(const TKey &p_key) const { + uint32_t pos = 0; + bool exists = _lookup_pos(p_key, pos); + + if (exists) { + return &values[pos]; + } + return nullptr; + } + + TValue *lookup_ptr(const TKey &p_key) { uint32_t pos = 0; bool exists = _lookup_pos(p_key, pos); |