summaryrefslogtreecommitdiffstats
path: root/core/object/class_db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/object/class_db.cpp')
-rw-r--r--core/object/class_db.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index a602dc9fb8..760f3bfd0c 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -53,8 +53,10 @@ MethodDefinition D_METHODP(const char *p_name, const char *const **p_args, uint3
#endif
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;
}
@@ -165,6 +167,10 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
OBJTYPE_RLOCK;
#ifdef DEBUG_METHODS_ENABLED
+ if (api_hashes_cache.has(p_api)) {
+ return api_hashes_cache[p_api];
+ }
+
uint64_t hash = hash_murmur3_one_64(HashMapHasherDefault::hash(VERSION_FULL_CONFIG));
List<StringName> class_list;
@@ -290,7 +296,14 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
}
}
- return hash_fmix32(hash);
+ hash = hash_fmix32(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;
#endif