Add peace-of-mind checks to API hash caching
This commit is contained in:
parent
e0e93ce094
commit
a79e71ad58
1 changed files with 7 additions and 1 deletions
|
@ -56,6 +56,7 @@ ClassDB::APIType ClassDB::current_api = API_CORE;
|
||||||
HashMap<ClassDB::APIType, uint64_t> ClassDB::api_hashes_cache;
|
HashMap<ClassDB::APIType, uint64_t> ClassDB::api_hashes_cache;
|
||||||
|
|
||||||
void ClassDB::set_current_api(APIType p_api) {
|
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;
|
current_api = p_api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +297,12 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = 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;
|
api_hashes_cache[p_api] = hash;
|
||||||
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue