From b58711804e9cca641927dbdebe281488e475352b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Apr 2018 13:41:29 +0200 Subject: Use Identifier by value and don't new them anymore Change-Id: Ib25c08027013217657beb2675dafa9a8c85cbaf9 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4identifier_p.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/qml/jsruntime/qv4identifier_p.h') diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h index f3935950c8..660cc2db05 100644 --- a/src/qml/jsruntime/qv4identifier_p.h +++ b/src/qml/jsruntime/qv4identifier_p.h @@ -66,12 +66,19 @@ struct ExecutionEngine; struct Identifier { - uint id; + quintptr id; + + static Identifier invalid() { return Identifier{0}; } + bool isValid() const { return id != 0; } + bool operator !() const { return id == 0; } + bool operator ==(const Identifier &other) const { return id == other.id; } + bool operator !=(const Identifier &other) const { return id != other.id; } + bool operator <(const Identifier &other) const { return id < other.id; } }; struct IdentifierHashEntry { - const Identifier *identifier; + Identifier identifier; int value; }; @@ -116,12 +123,12 @@ struct IdentifierHash QString findId(int value) const; protected: - IdentifierHashEntry *addEntry(const Identifier *i); - const IdentifierHashEntry *lookup(const Identifier *identifier) const; + IdentifierHashEntry *addEntry(Identifier i); + const IdentifierHashEntry *lookup(Identifier identifier) const; const IdentifierHashEntry *lookup(const QString &str) const; const IdentifierHashEntry *lookup(String *str) const; - const Identifier *toIdentifier(const QString &str) const; - const Identifier *toIdentifier(Heap::String *str) const; + const Identifier toIdentifier(const QString &str) const; + const Identifier toIdentifier(Heap::String *str) const; }; -- cgit v1.2.3