From 5214bb354b508cafc859b4a05b4e5f8ed44767e0 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sun, 30 Oct 2016 19:50:19 +0100 Subject: Avoid some copies --- Source/cmFileMonitor.cxx | 7 +++++-- Source/cmFileMonitor.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmOutputRequiredFilesCommand.cxx | 15 ++++++--------- Source/cmServerProtocol.cxx | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index b55341b..9844306 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -247,7 +247,10 @@ public: void StopWatching() final {} - void AppendCallback(cmFileMonitor::Callback cb) { CbList.push_back(cb); } + void AppendCallback(cmFileMonitor::Callback const& cb) + { + this->CbList.push_back(cb); + } std::string Path() const final { @@ -310,7 +313,7 @@ cmFileMonitor::~cmFileMonitor() } void cmFileMonitor::MonitorPaths(const std::vector& paths, - Callback cb) + Callback const& cb) { for (const auto& p : paths) { std::vector pathSegments; diff --git a/Source/cmFileMonitor.h b/Source/cmFileMonitor.h index e05f48d..48169b8 100644 --- a/Source/cmFileMonitor.h +++ b/Source/cmFileMonitor.h @@ -17,7 +17,7 @@ public: ~cmFileMonitor(); using Callback = std::function; - void MonitorPaths(const std::vector& paths, Callback cb); + void MonitorPaths(const std::vector& paths, Callback const& cb); void StopMonitoring(); std::vector WatchedFiles() const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 17d49e8..90caaf9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -963,7 +963,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule( (type == cmStateEnums::OBJECT_LIBRARY) || (type == cmStateEnums::GLOBAL_TARGET) || (type == cmStateEnums::UTILITY)) { - std::string name = target->GetName(); + std::string const& name = target->GetName(); if (emittedTargets.insert(name).second) { path = "... "; path += name; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index f3aa79c..7a17f2c 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -180,26 +180,23 @@ protected: while (cmSystemTools::GetLineFromStream(fin, line)) { if (cmHasLiteralPrefix(line.c_str(), "#include")) { // if it is an include line then create a string class - std::string currentline = line; - size_t qstart = currentline.find('\"', 8); + size_t qstart = line.find('\"', 8); size_t qend; // if a quote is not found look for a < if (qstart == std::string::npos) { - qstart = currentline.find('<', 8); + qstart = line.find('<', 8); // if a < is not found then move on if (qstart == std::string::npos) { - cmSystemTools::Error("unknown include directive ", - currentline.c_str()); + cmSystemTools::Error("unknown include directive ", line.c_str()); continue; } else { - qend = currentline.find('>', qstart + 1); + qend = line.find('>', qstart + 1); } } else { - qend = currentline.find('\"', qstart + 1); + qend = line.find('\"', qstart + 1); } // extract the file being included - std::string includeFile = - currentline.substr(qstart + 1, qend - qstart - 1); + std::string includeFile = line.substr(qstart + 1, qend - qstart - 1); // see if the include matches the regular expression if (!this->IncludeFileRegularExpression.find(includeFile)) { if (this->Verbose) { diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 857ce39..853704b 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -82,7 +82,7 @@ static void getCMakeInputs(const cmGlobalGenerator* gg, std::vector* tmpFiles) { const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/'; - const std::vector makefiles = gg->GetMakefiles(); + std::vector const& makefiles = gg->GetMakefiles(); for (auto it = makefiles.begin(); it != makefiles.end(); ++it) { const std::vector listFiles = (*it)->GetListFiles(); @@ -850,7 +850,7 @@ static Json::Value DumpTargetsList( return result; } -static Json::Value DumpProjectList(const cmake* cm, const std::string config) +static Json::Value DumpProjectList(const cmake* cm, std::string const& config) { Json::Value result = Json::arrayValue; @@ -1059,7 +1059,7 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings( } static void setBool(const cmServerRequest& request, const std::string& key, - std::function setter) + std::function const& setter) { if (request.Data[key].isNull()) { return; -- cgit v0.12