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:
@@ -100,3 +100,8 @@ const NameElement::Signature& NameElement::getSignature()
|
||||
{
|
||||
return m_signature;
|
||||
}
|
||||
|
||||
void NameElement::setSignature(std::wstring prefix, std::wstring postfix)
|
||||
{
|
||||
m_signature = Signature(std::move(prefix), std::move(postfix));
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
std::wstring getParameterString() const;
|
||||
|
||||
private:
|
||||
const std::wstring m_prefix;
|
||||
const std::wstring m_postfix;
|
||||
std::wstring m_prefix;
|
||||
std::wstring m_postfix;
|
||||
};
|
||||
|
||||
NameElement(std::wstring name);
|
||||
@@ -35,12 +35,14 @@ public:
|
||||
const std::wstring& getName() const;
|
||||
std::wstring getNameWithSignature() const;
|
||||
std::wstring getNameWithSignatureParameters() const;
|
||||
|
||||
bool hasSignature() const;
|
||||
const Signature& getSignature();
|
||||
void setSignature(std::wstring prefix, std::wstring postfix);
|
||||
|
||||
private:
|
||||
const std::wstring m_name;
|
||||
const Signature m_signature;
|
||||
Signature m_signature;
|
||||
};
|
||||
|
||||
#endif // NAME_ELEMENT_H
|
||||
|
||||
@@ -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