summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator3.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/cmLocalUnixMakefileGenerator3.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/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 9b9d22c..2d10021 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -116,10 +116,10 @@ void cmLocalUnixMakefileGenerator3::Generate()
this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES");
// Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+ for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
t != targets.end(); ++t) {
if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
@@ -172,8 +172,8 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
std::map<std::string, LocalObjectInfo>& localObjectFiles)
{
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
ti != targets.end(); ++ti) {
cmGeneratorTarget* gt = *ti;
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
@@ -382,9 +382,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// for each target we just provide a rule to cd up to the top and do a make
// on the target
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
std::string localName;
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+ for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
t != targets.end(); ++t) {
if (((*t)->GetType() == cmStateEnums::EXECUTABLE) ||
((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) ||
@@ -1562,8 +1562,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
this->WriteDivider(ruleFileStream);
ruleFileStream << "# Targets provided globally by CMake.\n"
<< "\n";
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- std::vector<cmGeneratorTarget*>::iterator glIt;
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
+ std::vector<cmGeneratorTarget*>::const_iterator glIt;
for (glIt = targets.begin(); glIt != targets.end(); ++glIt) {
if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) {
std::string targetString =