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

@@ -67,10 +67,12 @@ Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags)
ERR_FAIL_COND_V_MSG(fd[0] >= 0 || fd[1] >= 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
path = String("/tmp/") + p_path.replace("pipe://", "").replace("/", "_");
const CharString path_utf8 = path.utf8();
struct stat st = {};
int err = stat(path.utf8().get_data(), &st);
int err = stat(path_utf8.get_data(), &st);
if (err) {
if (mkfifo(path.utf8().get_data(), 0600) != 0) {
if (mkfifo(path_utf8.get_data(), 0600) != 0) {
last_error = ERR_FILE_CANT_OPEN;
return last_error;
}
@@ -79,7 +81,7 @@ Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags)
ERR_FAIL_COND_V_MSG(!S_ISFIFO(st.st_mode), ERR_ALREADY_IN_USE, "Pipe name is already used by file.");
}
int f = ::open(path.utf8().get_data(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
int f = ::open(path_utf8.get_data(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
if (f < 0) {
switch (errno) {
case ENOENT: {