summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorAaron Orenstein <aorenste@fb.com>2017-08-11 21:11:18 (GMT)
committerAaron Orenstein <aorenste@fb.com>2017-08-16 22:35:38 (GMT)
commitaf3fd6f22f317d4209ff679e4f7c8dd8d2d0f89f (patch)
treef032e00aecd7a92e828b4f8bf0d3229f3bab307a /Source/cmGlobalUnixMakefileGenerator3.cxx
parentc47c011c77bfd1bfb8d2060511a2b957ce181c62 (diff)
downloadCMake-af3fd6f22f317d4209ff679e4f7c8dd8d2d0f89f.zip
CMake-af3fd6f22f317d4209ff679e4f7c8dd8d2d0f89f.tar.gz
CMake-af3fd6f22f317d4209ff679e4f7c8dd8d2d0f89f.tar.bz2
Performance: Add an index to Change cmLocalGenerator::GeneratorTargets.
Add an index to Change cmLocalGenerator::GeneratorTargets for faster lookup by name. Also changed a bunch of uses of cmLocalGenerator::GetGeneratorTargets() to take const references instead of copying the vector. Represent generator targets as a map (name -> target) to make name lookups more efficient instead of looping through the entire vector to find the desired one.
Diffstat (limited to 'Source/cmGlobalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx23
1 files changed, 12 insertions, 11 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 23b3718..e42bf20 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -382,8 +382,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules(
for (unsigned int i = 0; i < lGenerators.size(); ++i) {
lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]);
// for all of out targets
- std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+ const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
l != tgts.end(); l++) {
if (((*l)->GetType() == cmStateEnums::EXECUTABLE) ||
((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) ||
@@ -414,8 +414,8 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
// The directory-level rule should depend on the target-level rules
// for all targets in the directory.
std::vector<std::string> depends;
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin();
l != targets.end(); ++l) {
cmGeneratorTarget* gtarget = *l;
int type = gtarget->GetType();
@@ -547,8 +547,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
for (i = 0; i < this->LocalGenerators.size(); ++i) {
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
// for each target Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
t != targets.end(); ++t) {
cmGeneratorTarget* gtarget = *t;
// Don't emit the same rule twice (e.g. two targets with the same
@@ -629,8 +629,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
depends.push_back("cmake_check_build_system");
// for each target Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
t != targets.end(); ++t) {
cmGeneratorTarget* gtarget = *t;
int type = gtarget->GetType();
@@ -807,7 +807,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
this->LocalGenerators.begin();
lgi != this->LocalGenerators.end(); ++lgi) {
cmLocalGenerator* lg = *lgi;
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
t != targets.end(); ++t) {
cmGeneratorTarget* gt = *t;
@@ -952,8 +952,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
// the targets
if (lg2 == lg || lg->IsRootMakefile()) {
// for each target Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+ const std::vector<cmGeneratorTarget*>& targets =
+ lg2->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
t != targets.end(); ++t) {
cmGeneratorTarget* target = *t;
cmStateEnums::TargetType type = target->GetType();