ENH: do not use count, find for map lookup
This commit is contained in:
parent
fd22157e55
commit
ec4331d273
@ -414,9 +414,10 @@ std::string cmBorlandMakefileGenerator::CreateMakeVariable(const char* s, const
|
|||||||
std::string unmodified = s;
|
std::string unmodified = s;
|
||||||
unmodified += s2;
|
unmodified += s2;
|
||||||
// see if th
|
// see if th
|
||||||
if(m_MakeVariableMap.count(unmodified))
|
std::map<cmStdString, cmStdString>::iterator i = m_MakeVariableMap.find(unmodified);
|
||||||
|
if(i != m_MakeVariableMap.end())
|
||||||
{
|
{
|
||||||
return m_MakeVariableMap[unmodified];
|
return i->second;
|
||||||
}
|
}
|
||||||
std::string ret = unmodified;
|
std::string ret = unmodified;
|
||||||
// if the string is greater the 32 chars it is an invalid vairable name
|
// if the string is greater the 32 chars it is an invalid vairable name
|
||||||
|
@ -443,31 +443,34 @@ void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
|||||||
|
|
||||||
void cmCacheManager::RemoveCacheEntry(const char* key)
|
void cmCacheManager::RemoveCacheEntry(const char* key)
|
||||||
{
|
{
|
||||||
if(m_Cache.count(key))
|
CacheEntryMap::iterator i = m_Cache.find(key);
|
||||||
{
|
if(i != m_Cache.end())
|
||||||
m_Cache.erase(key);
|
{
|
||||||
}
|
m_Cache.erase(i);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to remove entry" << std::endl;
|
std::cerr << "Failed to remove entry:" << key << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
|
cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
|
||||||
{
|
{
|
||||||
if(m_Cache.count(key))
|
CacheEntryMap::iterator i = m_Cache.find(key);
|
||||||
|
if(i != m_Cache.end())
|
||||||
{
|
{
|
||||||
return &(m_Cache.find(key)->second);
|
return &i->second;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmCacheManager::GetCacheValue(const char* key) const
|
const char* cmCacheManager::GetCacheValue(const char* key) const
|
||||||
{
|
{
|
||||||
if(m_Cache.count(key))
|
CacheEntryMap::const_iterator i = m_Cache.find(key);
|
||||||
|
if(i != m_Cache.end())
|
||||||
{
|
{
|
||||||
return m_Cache.find(key)->second.m_Value.c_str();
|
return i->second.m_Value.c_str();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user