summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-09-02 20:06:43 (GMT)
committerBrad King <brad.king@kitware.com>2009-09-02 20:06:43 (GMT)
commit0af3b3b8028bfe01621887d115dfbdcd3890e602 (patch)
treeab73a0311cd6e2de0256cc63ecd5409630946376
parent7e20db0224571361d6d5f62fc58b12452bec826b (diff)
downloadCMake-0af3b3b8028bfe01621887d115dfbdcd3890e602.zip
CMake-0af3b3b8028bfe01621887d115dfbdcd3890e602.tar.gz
CMake-0af3b3b8028bfe01621887d115dfbdcd3890e602.tar.bz2
Speed up graph traversal for project->targets map
The cmGlobalGenerator::AddTargetDepends method traces the dependencies of targets recursively to collect the complete set of targets needed for a given project (for VS .sln files). This commit teaches the method to avoid tracing its dependencies more than once. Otherwise the code does an all-paths walk needlessly.
-rw-r--r--Source/cmGlobalGenerator.cxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index f4fa6f4..812cffd 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1971,14 +1971,12 @@ cmGlobalGenerator::AddTargetDepends(cmTarget* target,
projectTargets)
{
// add the target itself
- projectTargets.insert(target);
- // get the direct depends of target
- cmGlobalGenerator::TargetDependSet const& tset
- = this->GetTargetDirectDepends(*target);
- if(tset.size())
- {
- // if there are targets that depend on target
- // add them and their depends as well
+ if(projectTargets.insert(target).second)
+ {
+ // This is the first time we have encountered the target.
+ // Recursively follow its dependencies.
+ cmGlobalGenerator::TargetDependSet const& tset
+ = this->GetTargetDirectDepends(*target);
for(cmGlobalGenerator::TargetDependSet::const_iterator i =
tset.begin(); i != tset.end(); ++i)
{