avoid unnecessary copy in `openHeader()` - detected by upcoming clang-tidy check `performance-unnecessary-copy-on-last-use` by firewave · Pull Request #276 · cppcheck-opensource/simplecpp
Conversation
I looks like a false positive but using a non-POD variable in a ternary causes it to be copied - see https://reviews.llvm.org/D137205#3939210.
Since simplecpp also supports pre-C++11 standards std:move() could not be used and I refactored the code instead getting rid of the ternaries.
| ret = openHeaderRelative(f, sourcefile, header); | ||
| return ret.empty() ? openHeaderIncludePath(f, dui, header) : ret; | ||
| if (ret.empty()) | ||
| openHeaderIncludePath(f, dui, header); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing the return.
Like I pointed out in other PRs we need have tests which use include files (which need to exist on the filesystem).
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters