diff options
author | Ken Martin <ken.martin@kitware.com> | 2006-04-11 16:51:20 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2006-04-11 16:51:20 (GMT) |
commit | 535acdc7a093c44c2d052247d0bfdb90e9c279a0 (patch) | |
tree | 80d5ba7eb2fd31f5f5fe26bdf1c17f125b18229e | |
parent | acf33ba191156c65682166f31a01e5d184b482ed (diff) | |
download | CMake-535acdc7a093c44c2d052247d0bfdb90e9c279a0.zip CMake-535acdc7a093c44c2d052247d0bfdb90e9c279a0.tar.gz CMake-535acdc7a093c44c2d052247d0bfdb90e9c279a0.tar.bz2 |
ENH: some performance optimizations
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 22 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 5 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 20 | ||||
-rw-r--r-- | Source/cmMakefile.h | 1 |
5 files changed, 38 insertions, 16 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 57f2eb0..65bc4d5 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -584,7 +584,8 @@ void cmGlobalGenerator::Configure() // Setup relative path generation. this->ConfigureRelativePaths(); - + this->TotalTargets.clear(); + // start with this directory cmLocalGenerator *lg = this->CreateLocalGenerator(); this->LocalGenerators.push_back(lg); @@ -1019,17 +1020,28 @@ cmTarget* cmGlobalGenerator::FindTarget(const char* project, const char* name) { std::vector<cmLocalGenerator*>* gens = &this->LocalGenerators; + // if project specific if(project) { gens = &this->ProjectMap[project]; + for(unsigned int i = 0; i < gens->size(); ++i) + { + cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name); + if(ret) + { + return ret; + } + } } - for(unsigned int i = 0; i < gens->size(); ++i) + // if all projects/directories + else { - cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name); - if(ret) + std::map<cmStdString,cmTarget *>::iterator i = this->TotalTargets.find(name); + if (i == this->TotalTargets.end()) { - return ret; + return 0; } + return i->second; } return 0; } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index d8e35ae..d3e3f30 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -175,6 +175,9 @@ public: configuration. This is valid during generation only. */ cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; } + void AddTarget(cmTargets::value_type &v) { + this->TotalTargets.insert(std::pair<cmStdString,cmTarget *>(v.first,&v.second));}; + /** Support for multiple custom command outputs. */ virtual void CheckMultipleOutputs(cmMakefile* mf, bool verbose); @@ -233,6 +236,9 @@ private: // using relative paths is unsafe. std::string RelativePathTopSource; std::string RelativePathTopBinary; + + // this is used to improve performance + std::map<cmStdString,cmTarget *> TotalTargets; }; #endif diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 303470f..9ae5439 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -709,10 +709,8 @@ cmLocalUnixMakefileGenerator3 std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(cmTarget& target) { - std::string dir = this->Makefile->GetStartOutputDirectory(); - dir += "/"; + std::string dir = this->HomeRelativeOutputPath; dir += this->GetTargetDirectory(target); - dir = cmSystemTools::RelativePath(this->Makefile->GetHomeOutputDirectory(), dir.c_str()); return this->Convert(dir.c_str(),NONE,MAKEFILE); } @@ -907,6 +905,7 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands, // Echo one line at a time. std::string line; + line.reserve(200); for(const char* c = text;; ++c) { if(*c == '\n' || *c == '\0') diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3d3b2d1..d53f979 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -774,7 +774,9 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all, target.GetPostBuildCommands().push_back(cc); // Add the target to the set of targets. - this->Targets.insert(cmTargets::value_type(utilityName, target)); + cmTargets::iterator it = + this->Targets.insert(cmTargets::value_type(utilityName,target)).first; + this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it); } void cmMakefile::AddDefineFlag(const char* flag) @@ -1152,7 +1154,9 @@ void cmMakefile::AddLibrary(const char* lname, int shared, target.GetSourceLists() = srcs; target.SetMakefile(this); this->AddGlobalLinkInformation(lname, target); - this->Targets.insert(cmTargets::value_type(lname,target)); + cmTargets::iterator it = + this->Targets.insert(cmTargets::value_type(lname,target)).first; + this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it); } cmTarget* cmMakefile::AddExecutable(const char *exeName, @@ -1166,6 +1170,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName, this->AddGlobalLinkInformation(exeName, target); cmTargets::iterator it = this->Targets.insert(cmTargets::value_type(exeName,target)).first; + this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it); return &it->second; } @@ -2560,14 +2565,13 @@ bool cmMakefile::GetPropertyAsBool(const char* prop) const cmTarget* cmMakefile::FindTarget(const char* name) { cmTargets& tgts = this->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) + + cmTargets::iterator i = tgts.find(name); + if (i == tgts.end()) { - if(l->first == name) - { - return &l->second; - } + return 0; } - return 0; + return &i->second; } cmTest* cmMakefile::CreateTest(const char* testName) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e59e90e..1651b49 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -414,6 +414,7 @@ public: cmTarget* FindTarget(const char* name); + /** * Get a list of include directories in the build. */ |