From 17ffb6eac5c5e402b936cd0293f64ef1568ef3b5 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 20 Nov 2022 00:27:25 +0100 Subject: [PATCH] avoid unnecessary copy in `openHeader()` - detected by upcoming clang-tidy check `performance-unnecessary-copy-on-last-use` --- simplecpp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/simplecpp.cpp b/simplecpp.cpp index 4aac986f..32d2b007 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -2862,11 +2862,15 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const if (systemheader) { ret = openHeaderIncludePath(f, dui, header); - return ret.empty() ? openHeaderRelative(f, sourcefile, header) : ret; + if (ret.empty()) + return openHeaderRelative(f, sourcefile, header); + return ret; } ret = openHeaderRelative(f, sourcefile, header); - return ret.empty() ? openHeaderIncludePath(f, dui, header) : ret; + if (ret.empty()) + openHeaderIncludePath(f, dui, header); + return ret; } static std::string getFileName(const std::map &filedata, const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader)