summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2020-01-16 04:15:45 (GMT)
committerTim Blechmann <tim@klingt.org>2020-01-16 04:22:25 (GMT)
commit5da3d01fd18c55cf3bfbf28a376a19d6e3e53ed6 (patch)
tree895f31e5ef776057c9a3351cd5dddcf64c9ec4dc
parent9f1ce93d92ec33e879ef593de021d0b577de6c68 (diff)
downloadCMake-5da3d01fd18c55cf3bfbf28a376a19d6e3e53ed6.zip
CMake-5da3d01fd18c55cf3bfbf28a376a19d6e3e53ed6.tar.gz
CMake-5da3d01fd18c55cf3bfbf28a376a19d6e3e53ed6.tar.bz2
cmSourceFile: avoid unnnecessary copies
the copies in `cmSourceFile::FindFullPath` are one of the hotspots of my build system: we can easily avoid them by capturing by reference instead of by value
-rw-r--r--Source/cmSourceFile.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 2a345eb..60adf7f 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -128,7 +128,7 @@ bool cmSourceFile::FindFullPath(std::string* error)
// The file is not generated. It must exist on disk.
cmMakefile const* makefile = this->Location.GetMakefile();
// Location path
- std::string const lPath = this->Location.GetFullPath();
+ std::string const& lPath = this->Location.GetFullPath();
// List of extension lists
std::array<std::vector<std::string> const*, 2> const extsLists = {
{ &makefile->GetCMakeInstance()->GetSourceExtensions(),
@@ -145,7 +145,7 @@ bool cmSourceFile::FindFullPath(std::string* error)
return true;
}
// Try full path with extension
- for (auto exts : extsLists) {
+ for (auto& exts : extsLists) {
for (std::string const& ext : *exts) {
if (!ext.empty()) {
std::string extPath = cmStrCat(fullPath, '.', ext);