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:
Eberhard Graether
2018-09-21 14:48:51 +02:00
parent 513988e51b
commit 56dcddfb83
43 changed files with 752 additions and 1236 deletions
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
}