aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Names.h
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-12-17 07:14:28 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-01-13 07:28:47 +0000
commit675abca1caad1c295330caa5e9b42cc812caee83 (patch)
tree126dcff158f624de28958944d3fa6a38be3c1c18 /src/libs/3rdparty/cplusplus/Names.h
parent0e7774e75dc74e9599fb5100c3c9c54187c56aa8 (diff)
Use std::unordered_map instead of std::map
In theory it should be faster. Change-Id: Ibf6ce8c5dced5a075b57f89ce6e2d5ed1c5d6be7 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Names.h')
-rw-r--r--src/libs/3rdparty/cplusplus/Names.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libs/3rdparty/cplusplus/Names.h b/src/libs/3rdparty/cplusplus/Names.h
index 6f9480b195..7b8783740d 100644
--- a/src/libs/3rdparty/cplusplus/Names.h
+++ b/src/libs/3rdparty/cplusplus/Names.h
@@ -113,6 +113,11 @@ public:
bool match(const TemplateArgument &otherTy, Matcher *matcher = nullptr) const;
+ size_t hash() const
+ {
+ return _expressionTy.hash() ^ std::hash<const NumericLiteral *>()(_numericLiteral);
+ }
+
private:
FullySpecifiedType _expressionTy;
const NumericLiteral *_numericLiteral = nullptr;
@@ -145,10 +150,13 @@ public:
TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); }
bool isSpecialization() const { return _isSpecialization; }
- // Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::map)
- struct Compare {
+ // Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::unordered_map)
+ struct Equals {
bool operator()(const TemplateNameId *name, const TemplateNameId *other) const;
};
+ struct Hash {
+ size_t operator()(const TemplateNameId *name) const;
+ };
protected:
void accept0(NameVisitor *visitor) const override;