summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-01-05 20:00:57 (GMT)
committerBrad King <brad.king@kitware.com>2009-01-05 20:00:57 (GMT)
commited3bb743f4c2687187e1721c5ccc64dd06cc3db5 (patch)
treeb29e9e94d7f4a770aa3fd4d4cf980b9ff78f699f /Source/cmMakefile.cxx
parentb5f3d4be61a9613abc7288f1cf31248412bfc50d (diff)
downloadCMake-ed3bb743f4c2687187e1721c5ccc64dd06cc3db5.zip
CMake-ed3bb743f4c2687187e1721c5ccc64dd06cc3db5.tar.gz
CMake-ed3bb743f4c2687187e1721c5ccc64dd06cc3db5.tar.bz2
ENH: Improve test property speed with a map
Previously we stored a vector of tests to preserve their order. Property set/get operations would do a linear search for matching tests. This uses a map to efficiently look up tests while keeping the original order with a vector for test file generation.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx31
1 files changed, 14 insertions, 17 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 424ca00..7442318 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -108,6 +108,7 @@ cmMakefile::cmMakefile(const cmMakefile& mf)
this->Targets = mf.Targets;
this->SourceFiles = mf.SourceFiles;
this->Tests = mf.Tests;
+ this->OrderedTests = mf.OrderedTests;
this->IncludeDirectories = mf.IncludeDirectories;
this->LinkDirectories = mf.LinkDirectories;
this->SystemIncludeDirectories = mf.SystemIncludeDirectories;
@@ -182,10 +183,10 @@ cmMakefile::~cmMakefile()
{
delete *i;
}
- for(std::vector<cmTest*>::iterator i = this->Tests.begin();
+ for(std::map<cmStdString, cmTest*>::iterator i = this->Tests.begin();
i != this->Tests.end(); ++i)
{
- delete *i;
+ delete i->second;
}
for(std::vector<cmTarget*>::iterator
i = this->ImportedTargetsOwned.begin();
@@ -3117,6 +3118,7 @@ cmTarget* cmMakefile::FindTarget(const char* name)
return 0;
}
+//----------------------------------------------------------------------------
cmTest* cmMakefile::CreateTest(const char* testName)
{
if ( !testName )
@@ -3131,35 +3133,30 @@ cmTest* cmMakefile::CreateTest(const char* testName)
test = new cmTest;
test->SetName(testName);
test->SetMakefile(this);
- this->Tests.push_back(test);
+ this->Tests[testName] = test;
+ this->OrderedTests.push_back(test);
return test;
}
+//----------------------------------------------------------------------------
cmTest* cmMakefile::GetTest(const char* testName) const
{
- if ( !testName )
+ if(testName)
{
- return 0;
- }
- std::vector<cmTest*>::const_iterator it;
- for ( it = this->Tests.begin(); it != this->Tests.end(); ++ it )
- {
- if ( strcmp((*it)->GetName(), testName) == 0 )
+ std::map<cmStdString, cmTest*>::const_iterator
+ mi = this->Tests.find(testName);
+ if(mi != this->Tests.end())
{
- return *it;
+ return mi->second;
}
}
return 0;
}
+//----------------------------------------------------------------------------
const std::vector<cmTest*> *cmMakefile::GetTests() const
{
- return &this->Tests;
-}
-
-std::vector<cmTest*> *cmMakefile::GetTests()
-{
- return &this->Tests;
+ return &this->OrderedTests;
}
std::string cmMakefile::GetListFileStack()