Use std::unordered_map instead of std::map

In theory it should be faster.

Change-Id: Ibf6ce8c5dced5a075b57f89ce6e2d5ed1c5d6be7
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2020-12-17 07:14:28 +01:00
parent 0e7774e75d
commit 675abca1ca
8 changed files with 73 additions and 32 deletions

View File

@@ -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;