From 94ef3729bf0a190ef05faccbec8a19aaa17bbce3 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Thu, 26 Jan 2023 11:17:43 +0100 Subject: [PATCH] Syscalls: Avoid unnecessary string copies and clean up error handling --- Source/Tests/LinuxSyscalls/Syscalls.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Source/Tests/LinuxSyscalls/Syscalls.cpp b/Source/Tests/LinuxSyscalls/Syscalls.cpp index 2e7a47ca1..a6a71ca0f 100644 --- a/Source/Tests/LinuxSyscalls/Syscalls.cpp +++ b/Source/Tests/LinuxSyscalls/Syscalls.cpp @@ -189,7 +189,7 @@ static bool IsShebangFile(std::span Data) { if (Argument.empty()) { continue; } - ShebangArguments.emplace_back(Argument); + ShebangArguments.push_back(std::move(Argument)); } // Executable argument @@ -198,16 +198,12 @@ static bool IsShebangFile(std::span Data) { // If the filename is absolute then prepend the rootfs // If it is relative then don't append the rootfs if (ShebangProgram[0] == '/') { - std::string RootFS = FEX::HLE::_SyscallHandler->RootFSPath(); - ShebangProgram = RootFS + ShebangProgram; + ShebangProgram = FEX::HLE::_SyscallHandler->RootFSPath() + ShebangProgram; } std::error_code ec; bool exists = std::filesystem::exists(ShebangProgram, ec); - if (ec || !exists) { - return false; - } - return true; + return !ec && exists; } return false;