Skip to content

Commit 501c9c6

Browse files
authored
avoid unnecessary copy in openHeader() - detected by upcoming clang-tidy check performance-unnecessary-copy-on-last-use (#276)
1 parent 3df6160 commit 501c9c6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

simplecpp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,11 +2862,15 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
28622862

28632863
if (systemheader) {
28642864
ret = openHeaderIncludePath(f, dui, header);
2865-
return ret.empty() ? openHeaderRelative(f, sourcefile, header) : ret;
2865+
if (ret.empty())
2866+
return openHeaderRelative(f, sourcefile, header);
2867+
return ret;
28662868
}
28672869

28682870
ret = openHeaderRelative(f, sourcefile, header);
2869-
return ret.empty() ? openHeaderIncludePath(f, dui, header) : ret;
2871+
if (ret.empty())
2872+
openHeaderIncludePath(f, dui, header);
2873+
return ret;
28702874
}
28712875

28722876
static std::string getFileName(const std::map<std::string, simplecpp::TokenList *> &filedata, const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader)

0 commit comments

Comments
 (0)