summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-04-26 11:36:09 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-04-26 11:36:09 +0200
commit51951a59d6c2d7ba9ecc8e48888b099429219300 (patch)
tree78e8683f4b13f291f4882090ac9f3868c12efe72
parentfdb058f4df89d360bc1e7363ad2d09bdabc86aad (diff)
parenta79e71ad5870659f4b2ba18334ab058a92a2b1ad (diff)
downloadredot-engine-51951a59d6c2d7ba9ecc8e48888b099429219300.tar.gz
Merge pull request #76467 from RandomShaper/doc_cache_peace_of_mind
Add peace-of-mind checks to API hash caching
-rw-r--r--core/object/class_db.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index d920ae6ca0..760f3bfd0c 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -56,6 +56,7 @@ ClassDB::APIType ClassDB::current_api = API_CORE;
HashMap<ClassDB::APIType, uint64_t> ClassDB::api_hashes_cache;
void ClassDB::set_current_api(APIType p_api) {
+ DEV_ASSERT(!api_hashes_cache.has(p_api)); // This API type may not be suitable for caching of hash if it can change later.
current_api = p_api;
}
@@ -296,7 +297,12 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
}
hash = hash_fmix32(hash);
- api_hashes_cache[p_api] = hash;
+
+ // Extension API changes at runtime; let's just not cache them by now.
+ if (p_api != API_EXTENSION && p_api != API_EDITOR_EXTENSION) {
+ api_hashes_cache[p_api] = hash;
+ }
+
return hash;
#else
return 0;