summaryrefslogtreecommitdiffstats
path: root/Source/cmSetTestsPropertiesCommand.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/cmSetTestsPropertiesCommand.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/cmSetTestsPropertiesCommand.cxx')
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx27
1 files changed, 7 insertions, 20 deletions
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index 8a849b3..cfb4a85 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -100,30 +100,17 @@ bool cmSetTestsPropertiesCommand
std::vector<std::string> &propertyPairs,
cmMakefile *mf, std::string &errors)
{
- std::vector<cmTest*> &tests = *mf->GetTests();
- // now loop over all the targets
- unsigned int k;
- bool found = false;
- // if the file is already in the makefile just set properites on it
- std::vector<cmTest*>::iterator it;
- for ( it = tests.begin(); it != tests.end(); ++ it )
+ if(cmTest* test = mf->GetTest(tname))
{
- cmTest* test = *it;
- if ( !strcmp(test->GetName(),tname ))
+ // now loop through all the props and set them
+ unsigned int k;
+ for (k = 0; k < propertyPairs.size(); k = k + 2)
{
- // now loop through all the props and set them
- for (k = 0; k < propertyPairs.size(); k = k + 2)
- {
- test->SetProperty(propertyPairs[k].c_str(),
- propertyPairs[k+1].c_str());
- }
- found = true;
- break;
+ test->SetProperty(propertyPairs[k].c_str(),
+ propertyPairs[k+1].c_str());
}
}
-
- // if file is not already in the makefile, then add it
- if ( ! found )
+ else
{
errors = "Can not find test to add properties to: ";
errors += tname;