@@ -328,19 +328,22 @@ Error ResourceUID::update_cache() {
328328}
329329
330330String ResourceUID::get_path_from_cache (Ref<FileAccess> &p_cache_file, const String &p_uid_string) {
331- const uint32_t entry_count = p_cache_file->get_32 ();
332- CharString cs;
333- for (uint32_t i = 0 ; i < entry_count; i++) {
334- int64_t id = p_cache_file->get_64 ();
335- int32_t len = p_cache_file->get_32 ();
336- cs.resize_uninitialized (len + 1 );
337- ERR_FAIL_COND_V (cs.size () != len + 1 , String ());
338- cs[len] = 0 ;
339- int32_t rl = p_cache_file->get_buffer ((uint8_t *)cs.ptrw (), len);
340- ERR_FAIL_COND_V (rl != len, String ());
341-
342- if (singleton->id_to_text (id) == p_uid_string) {
343- return String::utf8 (cs.get_data ());
331+ const int64_t uid_from_string = singleton->text_to_id (p_uid_string);
332+ if (uid_from_string != INVALID_ID) {
333+ const uint32_t entry_count = p_cache_file->get_32 ();
334+ CharString cs;
335+ for (uint32_t i = 0 ; i < entry_count; i++) {
336+ int64_t id = p_cache_file->get_64 ();
337+ int32_t len = p_cache_file->get_32 ();
338+ cs.resize_uninitialized (len + 1 );
339+ ERR_FAIL_COND_V (cs.size () != len + 1 , String ());
340+ cs[len] = 0 ;
341+ int32_t rl = p_cache_file->get_buffer ((uint8_t *)cs.ptrw (), len);
342+ ERR_FAIL_COND_V (rl != len, String ());
343+
344+ if (id == uid_from_string) {
345+ return String::utf8 (cs.get_data ());
346+ }
344347 }
345348 }
346349 return String ();
0 commit comments