cxx: Improved performance of CxxAstVisitor, CxxNameResolver and CxxName types
* use unique_ptr for CxxName handling * create CxxNameResolver from other * improved string handling in CxxName types * only traverse decls within projects * use macro in ast visitor to call into each component instead of virtual calls * improved CxxName caching performance * refactored CxxNameResolver classes to use less locals
This commit is contained in:
@@ -30,7 +30,7 @@ OrderedCache<KeyType, ValType>::OrderedCache(std::function<ValType(const KeyType
|
||||
template <typename KeyType, typename ValType>
|
||||
ValType OrderedCache<KeyType, ValType>::getValue(const KeyType& key)
|
||||
{
|
||||
typename std::map<KeyType, ValType>::const_iterator it = m_map.find(key);
|
||||
auto it = m_map.find(key);
|
||||
if (it != m_map.end())
|
||||
{
|
||||
++m_hitCount;
|
||||
@@ -38,7 +38,7 @@ ValType OrderedCache<KeyType, ValType>::getValue(const KeyType& key)
|
||||
}
|
||||
++m_missCount;
|
||||
ValType val = m_calculator(key);
|
||||
m_map.insert(std::pair<KeyType, ValType>(key, val));
|
||||
m_map.emplace(key, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ UnorderedCache<KeyType, ValType, Hasher>::UnorderedCache(std::function<ValType(c
|
||||
template <typename KeyType, typename ValType, typename Hasher>
|
||||
ValType UnorderedCache<KeyType, ValType, Hasher>::getValue(const KeyType& key)
|
||||
{
|
||||
typename std::unordered_map<KeyType, ValType, Hasher>::const_iterator it = m_map.find(key);
|
||||
auto it = m_map.find(key);
|
||||
if (it != m_map.end())
|
||||
{
|
||||
++m_hitCount;
|
||||
@@ -38,7 +38,7 @@ ValType UnorderedCache<KeyType, ValType, Hasher>::getValue(const KeyType& key)
|
||||
}
|
||||
++m_missCount;
|
||||
ValType val = m_calculator(key);
|
||||
m_map.insert(std::pair<KeyType, ValType>(key, val));
|
||||
m_map.emplace(key, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user