瀏覽代碼

Add mutable OAHashMap::lookup_ptr function to fix mutability.

AndreaCatania 3 年之前
父節點
當前提交
4066349488
共有 1 個文件被更改,包括 11 次插入7 次删除
  1. 11 7
      core/templates/oa_hash_map.h

+ 11 - 7
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);