1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Optimize calls of utf8 in a few spots to avoid calling it more than once.

This commit is contained in:
Lukas Tenbrink
2025-01-07 17:24:21 +01:00
parent aa65940a85
commit 0fddf6a824
4 changed files with 13 additions and 12 deletions

View File

@@ -311,18 +311,16 @@ bool FileAccessUnix::store_buffer(const uint8_t *p_src, uint64_t p_length) {
}
bool FileAccessUnix::file_exists(const String &p_path) {
int err;
struct stat st = {};
String filename = fix_path(p_path);
const CharString filename_utf8 = fix_path(p_path).utf8();
// Does the name exist at all?
err = stat(filename.utf8().get_data(), &st);
if (err) {
if (stat(filename_utf8.get_data(), &st)) {
return false;
}
// See if we have access to the file
if (access(filename.utf8().get_data(), F_OK)) {
if (access(filename_utf8.get_data(), F_OK)) {
return false;
}