mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #108981 from DeeJayLSP/faster-uid-path-from-cache
Make getting a path from UID cache slightly faster
This commit is contained in:
commit
9a9e64a6ee
1 changed files with 15 additions and 12 deletions
|
|
@ -328,19 +328,22 @@ Error ResourceUID::update_cache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
String ResourceUID::get_path_from_cache(Ref<FileAccess> &p_cache_file, const String &p_uid_string) {
|
String ResourceUID::get_path_from_cache(Ref<FileAccess> &p_cache_file, const String &p_uid_string) {
|
||||||
const uint32_t entry_count = p_cache_file->get_32();
|
const int64_t uid_from_string = singleton->text_to_id(p_uid_string);
|
||||||
CharString cs;
|
if (uid_from_string != INVALID_ID) {
|
||||||
for (uint32_t i = 0; i < entry_count; i++) {
|
const uint32_t entry_count = p_cache_file->get_32();
|
||||||
int64_t id = p_cache_file->get_64();
|
CharString cs;
|
||||||
int32_t len = p_cache_file->get_32();
|
for (uint32_t i = 0; i < entry_count; i++) {
|
||||||
cs.resize_uninitialized(len + 1);
|
int64_t id = p_cache_file->get_64();
|
||||||
ERR_FAIL_COND_V(cs.size() != len + 1, String());
|
int32_t len = p_cache_file->get_32();
|
||||||
cs[len] = 0;
|
cs.resize_uninitialized(len + 1);
|
||||||
int32_t rl = p_cache_file->get_buffer((uint8_t *)cs.ptrw(), len);
|
ERR_FAIL_COND_V(cs.size() != len + 1, String());
|
||||||
ERR_FAIL_COND_V(rl != len, String());
|
cs[len] = 0;
|
||||||
|
int32_t rl = p_cache_file->get_buffer((uint8_t *)cs.ptrw(), len);
|
||||||
|
ERR_FAIL_COND_V(rl != len, String());
|
||||||
|
|
||||||
if (singleton->id_to_text(id) == p_uid_string) {
|
if (id == uid_from_string) {
|
||||||
return String::utf8(cs.get_data());
|
return String::utf8(cs.get_data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return String();
|
return String();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue