cmDefinitions: Make GetInternal method static.

For some reason, using recursion here is faster to configure ParaView
than using a loop.  Probably some compiler optimization is inhibited
by using a loop.

Co-Author: Brad King <brad.king@kitware.com>
This commit is contained in:
Stephen Kelly 2015-05-01 01:13:38 +02:00
parent 7a5039fa6c
commit a7ce0c7bc0
2 changed files with 12 additions and 14 deletions

View File

@ -22,20 +22,20 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(
std::list<cmDefinitions>::reverse_iterator rbegin,
std::list<cmDefinitions>::reverse_iterator rend)
{
assert(&*rbegin == this);
MapType::const_iterator i = this->Map.find(key);
if(i != this->Map.end())
assert(rbegin != rend);
MapType::const_iterator i = rbegin->Map.find(key);
if (i != rbegin->Map.end())
{
return i->second;
}
++rbegin;
if(rbegin == rend)
std::list<cmDefinitions>::reverse_iterator rit = rbegin;
++rit;
if (rit == rend)
{
return cmDefinitions::NoDef;
}
// Query the parent scope and store the result locally.
Def def = rbegin->GetInternal(key, rbegin, rend);
return this->Map.insert(MapType::value_type(key, def)).first->second;
Def const& def = cmDefinitions::GetInternal(key, rit, rend);
return rbegin->Map.insert(MapType::value_type(key, def)).first->second;
}
//----------------------------------------------------------------------------
@ -43,7 +43,7 @@ const char* cmDefinitions::Get(const std::string& key,
std::list<cmDefinitions>::reverse_iterator rbegin,
std::list<cmDefinitions>::reverse_iterator rend)
{
Def const& def = this->GetInternal(key, rbegin, rend);
Def const& def = cmDefinitions::GetInternal(key, rbegin, rend);
return def.Exists? def.c_str() : 0;
}

View File

@ -73,11 +73,9 @@ private:
#endif
MapType Map;
// Internal query and update methods.
Def const& GetInternal(const std::string& key,
std::list<cmDefinitions>::reverse_iterator rbegin,
std::list<cmDefinitions>::reverse_iterator rend);
static Def const& GetInternal(const std::string& key,
std::list<cmDefinitions>::reverse_iterator rbegin,
std::list<cmDefinitions>::reverse_iterator rend);
void MakeClosure(std::set<std::string>& undefined,
std::list<cmDefinitions>::const_reverse_iterator rbegin,
std::list<cmDefinitions>::const_reverse_iterator rend);