From 1e0353e179dbe8ee1ce7dc36424ff608cc9445f9 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 26 Jul 2022 15:09:11 +0200 Subject: [PATCH] Alos add a const version of lookup_ptr for OAHashMap, similar to https://github.com/godotengine/godot/commit/62e904483729f8b445f225528ac70b082303f3bd . --- core/oa_hash_map.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h index 6c38e4d71..360d88f9e 100644 --- a/core/oa_hash_map.h +++ b/core/oa_hash_map.h @@ -236,7 +236,18 @@ public: return false; } - 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);