[Cmake-commits] [cmake-commits] king committed cmGetPropertyCommand.cxx 1.9 1.10 cmMakefile.cxx 1.487 1.488 cmMakefile.h 1.238 1.239 cmSetPropertyCommand.cxx 1.8 1.9 cmSetTestsPropertiesCommand.cxx 1.7 1.8
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Jan 5 15:00:59 EST 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv19088/Source
Modified Files:
cmGetPropertyCommand.cxx cmMakefile.cxx cmMakefile.h
cmSetPropertyCommand.cxx cmSetTestsPropertiesCommand.cxx
Log Message:
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.
Index: cmSetTestsPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetTestsPropertiesCommand.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmSetTestsPropertiesCommand.cxx 23 Jan 2008 15:27:59 -0000 1.7
--- cmSetTestsPropertiesCommand.cxx 5 Jan 2009 20:00:57 -0000 1.8
***************
*** 101,128 ****
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 )
{
! cmTest* test = *it;
! if ( !strcmp(test->GetName(),tname ))
{
! // 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;
}
}
!
! // if file is not already in the makefile, then add it
! if ( ! found )
{
errors = "Can not find test to add properties to: ";
--- 101,115 ----
cmMakefile *mf, std::string &errors)
{
! if(cmTest* test = mf->GetTest(tname))
{
! // now loop through all the props and set them
! unsigned int k;
! for (k = 0; k < propertyPairs.size(); k = k + 2)
{
! test->SetProperty(propertyPairs[k].c_str(),
! propertyPairs[k+1].c_str());
}
}
! else
{
errors = "Can not find test to add properties to: ";
Index: cmGetPropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGetPropertyCommand.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -C 2 -d -r1.9 -r1.10
*** cmGetPropertyCommand.cxx 1 Apr 2008 19:22:30 -0000 1.9
--- cmGetPropertyCommand.cxx 5 Jan 2009 20:00:56 -0000 1.10
***************
*** 329,341 ****
// Loop over all tests looking for matching names.
! std::vector<cmTest*> const& tests = *this->Makefile->GetTests();
! for(std::vector<cmTest*>::const_iterator ti = tests.begin();
! ti != tests.end(); ++ti)
{
! cmTest* test = *ti;
! if(test->GetName() == this->Name)
! {
! return this->StoreResult(test->GetProperty(this->PropertyName.c_str()));
! }
}
--- 329,335 ----
// Loop over all tests looking for matching names.
! if(cmTest* test = this->Makefile->GetTest(this->Name.c_str()))
{
! return this->StoreResult(test->GetProperty(this->PropertyName.c_str()));
}
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.487
retrieving revision 1.488
diff -C 2 -d -r1.487 -r1.488
*** cmMakefile.cxx 21 Nov 2008 21:32:39 -0000 1.487
--- cmMakefile.cxx 5 Jan 2009 20:00:56 -0000 1.488
***************
*** 109,112 ****
--- 109,113 ----
this->SourceFiles = mf.SourceFiles;
this->Tests = mf.Tests;
+ this->OrderedTests = mf.OrderedTests;
this->IncludeDirectories = mf.IncludeDirectories;
this->LinkDirectories = mf.LinkDirectories;
***************
*** 183,190 ****
delete *i;
}
! for(std::vector<cmTest*>::iterator i = this->Tests.begin();
i != this->Tests.end(); ++i)
{
! delete *i;
}
for(std::vector<cmTarget*>::iterator
--- 184,191 ----
delete *i;
}
! for(std::map<cmStdString, cmTest*>::iterator i = this->Tests.begin();
i != this->Tests.end(); ++i)
{
! delete i->second;
}
for(std::vector<cmTarget*>::iterator
***************
*** 3118,3121 ****
--- 3119,3123 ----
}
+ //----------------------------------------------------------------------------
cmTest* cmMakefile::CreateTest(const char* testName)
{
***************
*** 3132,3151 ****
test->SetName(testName);
test->SetMakefile(this);
! this->Tests.push_back(test);
return test;
}
cmTest* cmMakefile::GetTest(const char* testName) const
{
! 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 )
{
! return *it;
}
}
--- 3134,3152 ----
test->SetName(testName);
test->SetMakefile(this);
! this->Tests[testName] = test;
! this->OrderedTests.push_back(test);
return test;
}
+ //----------------------------------------------------------------------------
cmTest* cmMakefile::GetTest(const char* testName) const
{
! if(testName)
{
! std::map<cmStdString, cmTest*>::const_iterator
! mi = this->Tests.find(testName);
! if(mi != this->Tests.end())
{
! return mi->second;
}
}
***************
*** 3153,3164 ****
}
const std::vector<cmTest*> *cmMakefile::GetTests() const
{
! return &this->Tests;
! }
!
! std::vector<cmTest*> *cmMakefile::GetTests()
! {
! return &this->Tests;
}
--- 3154,3161 ----
}
+ //----------------------------------------------------------------------------
const std::vector<cmTest*> *cmMakefile::GetTests() const
{
! return &this->OrderedTests;
}
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.238
retrieving revision 1.239
diff -C 2 -d -r1.238 -r1.239
*** cmMakefile.h 21 Nov 2008 21:32:39 -0000 1.238
--- cmMakefile.h 5 Jan 2009 20:00:57 -0000 1.239
***************
*** 738,742 ****
cmTest* GetTest(const char* testName) const;
const std::vector<cmTest*> *GetTests() const;
- std::vector<cmTest*> *GetTests();
/**
--- 738,741 ----
***************
*** 808,812 ****
// Tests
! std::vector<cmTest*> Tests;
// The include and link-library paths. These may have order
--- 807,812 ----
// Tests
! std::map<cmStdString, cmTest*> Tests;
! std::vector<cmTest*> OrderedTests;
// The include and link-library paths. These may have order
Index: cmSetPropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertyCommand.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -C 2 -d -r1.8 -r1.9
*** cmSetPropertyCommand.cxx 19 Aug 2008 15:43:51 -0000 1.8
--- cmSetPropertyCommand.cxx 5 Jan 2009 20:00:57 -0000 1.9
***************
*** 328,340 ****
bool cmSetPropertyCommand::HandleTestMode()
{
! // Loop over all tests looking for matching names.
! std::vector<cmTest*> const& tests = *this->Makefile->GetTests();
! for(std::vector<cmTest*>::const_iterator ti = tests.begin();
! ti != tests.end(); ++ti)
{
! cmTest* test = *ti;
! std::set<cmStdString>::iterator ni =
! this->Names.find(test->GetName());
! if(ni != this->Names.end())
{
if(this->HandleTest(test))
--- 328,339 ----
bool cmSetPropertyCommand::HandleTestMode()
{
! // Look for tests with all names given.
! std::set<cmStdString>::iterator next;
! for(std::set<cmStdString>::iterator ni = this->Names.begin();
! ni != this->Names.end(); ni = next)
{
! next = ni;
! ++next;
! if(cmTest* test = this->Makefile->GetTest(ni->c_str()))
{
if(this->HandleTest(test))
More information about the Cmake-commits
mailing list