From 7bc65770171924e550d2937b07b54b83b9fb59ab Mon Sep 17 00:00:00 2001 From: Aaron Orenstein Date: Fri, 18 Aug 2017 07:59:52 -0700 Subject: Performance: Fix a few more unnecessary vector copies missed in af3fd6f --- Source/cmGlobalGhsMultiGenerator.cxx | 6 +++--- Source/cmGlobalGhsMultiGenerator.h | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 12 ++++++++---- Source/cmGlobalXCodeGenerator.cxx | 14 +++++++------- Source/cmLocalGhsMultiGenerator.cxx | 4 ++-- Source/cmLocalVisualStudio10Generator.cxx | 4 ++-- Source/cmLocalVisualStudio7Generator.cxx | 17 +++++++++-------- Source/cmLocalXCodeGenerator.cxx | 8 ++++---- Source/cmServerProtocol.cxx | 2 +- 10 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 42ab4d9..788a179 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -260,7 +260,7 @@ void cmGlobalGhsMultiGenerator::Generate() for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { cmLocalGhsMultiGenerator* lg = static_cast(this->LocalGenerators[i]); - std::vector tgts = lg->GetGeneratorTargets(); + const std::vector& tgts = lg->GetGeneratorTargets(); this->UpdateBuildFiles(tgts); } } @@ -436,9 +436,9 @@ std::string cmGlobalGhsMultiGenerator::GetFileNameFromPath( } void cmGlobalGhsMultiGenerator::UpdateBuildFiles( - std::vector tgts) + const std::vector& tgts) { - for (std::vector::iterator tgtsI = tgts.begin(); + for (std::vector::const_iterator tgtsI = tgts.begin(); tgtsI != tgts.end(); ++tgtsI) { const cmGeneratorTarget* tgt = *tgtsI; if (IsTgtForBuild(tgt)) { diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 7b3eebb..05a3a3c 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -116,7 +116,7 @@ private: std::vector::const_iterator end, GhsMultiGpj::Types projType); static std::string GetFileNameFromPath(std::string const& path); - void UpdateBuildFiles(std::vector tgts); + void UpdateBuildFiles(const std::vector& tgts); bool IsTgtForBuild(const cmGeneratorTarget* tgt); std::vector TargetSubProjects; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 7a42b72..ed1ef1b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -320,10 +320,10 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets() cmGlobalVisualStudio7Generator::AddExtraIDETargets(); if (this->AddCheckTarget()) { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector tgts = + const std::vector& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. - for (std::vector::iterator ti = tgts.begin(); + for (std::vector::const_iterator ti = tgts.begin(); ti != tgts.end(); ++ti) { if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 87a22d1..f85e409 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -82,8 +82,10 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() // Now make all targets depend on the ALL_BUILD target for (std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - std::vector targets = (*i)->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = + (*i)->GetGeneratorTargets(); + for (std::vector::const_iterator t = + targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* tgt = *t; if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET || @@ -298,8 +300,10 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() std::vector& gen = it->second; for (std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - std::vector targets = (*i)->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = + (*i)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = + targets.begin(); ti != targets.end(); ++ti) { this->ComputeVSTargetDepends(*ti); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 071d49c..8f260ec 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -440,8 +440,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( continue; } - std::vector tgts = lg->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = lg->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); l++) { cmGeneratorTarget* target = *l; @@ -925,12 +925,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( cmLocalGenerator* gen, std::vector& targets) { this->SetCurrentLocalGenerator(gen); - std::vector tgts = + const std::vector& tgts = this->CurrentLocalGenerator->GetGeneratorTargets(); typedef std::map cmSortedTargets; cmSortedTargets sortedTargets; - for (std::vector::iterator l = tgts.begin(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); l++) { sortedTargets[(*l)->GetName()] = *l; } @@ -1210,7 +1210,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( void cmGlobalXCodeGenerator::ForceLinkerLanguages() { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector tgts = + const std::vector& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. for (std::vector::const_iterator ti = tgts.begin(); @@ -2706,8 +2706,8 @@ bool cmGlobalXCodeGenerator::CreateGroups( i != generators.end(); ++i) { cmMakefile* mf = (*i)->GetMakefile(); std::vector sourceGroups = mf->GetSourceGroups(); - std::vector tgts = (*i)->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = (*i)->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); l++) { cmGeneratorTarget* gtgt = *l; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 5f37af5..ab6774e 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -20,9 +20,9 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() void cmLocalGhsMultiGenerator::Generate() { - std::vector tgts = this->GetGeneratorTargets(); + const std::vector& tgts = this->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 85d4a73..db1776a 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -60,8 +60,8 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() void cmLocalVisualStudio10Generator::Generate() { - std::vector tgts = this->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = this->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd08e5b..857ce46 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -62,8 +62,8 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() void cmLocalVisualStudio7Generator::AddHelperCommands() { // Now create GUIDs for targets - std::vector tgts = this->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = this->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -91,8 +91,9 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() // specification source changes. if (cmSourceFile* sf = this->CreateVCProjBuildRule()) { // Add the rule to targets that need it. - std::vector tgts = this->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = + this->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; @@ -110,8 +111,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() // Visual Studio .NET 2003 Service Pack 1 will not run post-build // commands for targets in which no sources are built. Add dummy // rules to force these targets to build. - std::vector tgts = this->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = this->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::vector no_depends; @@ -150,10 +151,10 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() } // Get the set of targets in this directory. - std::vector tgts = this->GetGeneratorTargets(); + const std::vector& tgts = this->GetGeneratorTargets(); // Create the project file for each target. - for (std::vector::iterator l = tgts.begin(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 739ef43..355c394 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -42,8 +42,8 @@ void cmLocalXCodeGenerator::Generate() { cmLocalGenerator::Generate(); - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator iter = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { (*iter)->HasMacOSXRpathInstallNameDir(""); } @@ -53,8 +53,8 @@ void cmLocalXCodeGenerator::GenerateInstallRules() { cmLocalGenerator::GenerateInstallRules(); - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator iter = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { (*iter)->HasMacOSXRpathInstallNameDir(""); } diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index baaf11a..2063c82 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -903,7 +903,7 @@ static Json::Value DumpTargetsList( std::vector targetList; for (const auto& lgIt : generators) { - auto list = lgIt->GetGeneratorTargets(); + const auto& list = lgIt->GetGeneratorTargets(); targetList.insert(targetList.end(), list.begin(), list.end()); } std::sort(targetList.begin(), targetList.end()); -- cgit v0.12