cmFindLibraryCommand: Avoid repeating search for the same name

In FindNormalLibraryDirsPerName we consider one name at a time and
search the entire path.  Avoid repeated consideration of names by
removing each one from the list of candidates before considering the
next one.  This will not change behavior because we already know the
earlier candidates were not found on repeated considering anyway.
This commit is contained in:
Brad King 2015-09-01 13:39:55 -04:00
parent 72c11e5902
commit bf32b95efe
1 changed files with 9 additions and 2 deletions

View File

@ -203,6 +203,7 @@ struct cmFindLibraryHelper
} }
bool HasValidSuffix(std::string const& name); bool HasValidSuffix(std::string const& name);
void AddName(std::string const& name); void AddName(std::string const& name);
void SetName(std::string const& name);
bool CheckDirectory(std::string const& path); bool CheckDirectory(std::string const& path);
bool CheckDirectoryForName(std::string const& path, Name& name); bool CheckDirectoryForName(std::string const& path, Name& name);
}; };
@ -321,6 +322,13 @@ void cmFindLibraryHelper::AddName(std::string const& name)
this->Names.push_back(entry); this->Names.push_back(entry);
} }
//----------------------------------------------------------------------------
void cmFindLibraryHelper::SetName(std::string const& name)
{
this->Names.clear();
this->AddName(name);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmFindLibraryHelper::CheckDirectory(std::string const& path) bool cmFindLibraryHelper::CheckDirectory(std::string const& path)
{ {
@ -459,8 +467,7 @@ std::string cmFindLibraryCommand::FindNormalLibraryDirsPerName()
ni != this->Names.end() ; ++ni) ni != this->Names.end() ; ++ni)
{ {
// Switch to searching for this name. // Switch to searching for this name.
std::string const& name = *ni; helper.SetName(*ni);
helper.AddName(name);
// Search every directory. // Search every directory.
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator