From 9002a7c91492955480030706e2ce0e5bc9ef75d4 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <> Date: Fri, 9 Sep 2022 11:05:39 +0200 Subject: [PATCH] More optimized --- src/Common/unix/FileStream_unix.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Common/unix/FileStream_unix.cpp b/src/Common/unix/FileStream_unix.cpp index 4c8c1d16..2136120c 100644 --- a/src/Common/unix/FileStream_unix.cpp +++ b/src/Common/unix/FileStream_unix.cpp @@ -5,6 +5,7 @@ std::optional findPathCI(const fs::path& path) if (fs::exists(path)) return path; if (!path.has_parent_path()) return {}; auto parentPath = path.parent_path(); + std::string fName = path.filename().string(); if (!fs::exists(parentPath)) { auto tempParentPath = findPathCI(parentPath); @@ -12,13 +13,10 @@ std::optional findPathCI(const fs::path& path) parentPath = std::move(tempParentPath.value()); else return {}; + if (fs::exists(parentPath / fName)) + return parentPath / fName; } - std::string fName = path.filename().string(); - - if (fs::exists(parentPath / fName)) - return parentPath / fName; - std::error_code listErr; for (auto&& dirEntry: fs::directory_iterator(parentPath, listErr)) {