diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-03 15:51:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:17:17 +0000 |
commit | 13cc936859518b5fa378c7b8242d56ebf49ebce9 (patch) | |
tree | 22d3bd9c771417707c35b8891f69b72b718fb84d /src/qml/jsruntime/qv4identifier.cpp | |
parent | e9492e7b7b44c1f8cd5489d93463fc2b1f8b6d72 (diff) |
Remove the QString member from Identifier
First step to turning identifier into a simple int.
Change-Id: I4988587aa61f1f02ed80426ccbf00b685f38c829
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4identifier.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4identifier.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index c122bcb51a..77510d95f6 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qv4identifier_p.h" #include "qv4identifiertable_p.h" +#include "qv4string_p.h" QT_BEGIN_NAMESPACE @@ -150,18 +151,9 @@ const IdentifierHashEntry *IdentifierHash::lookup(const QString &str) const { if (!d) return nullptr; - Q_ASSERT(d->entries); - uint hash = String::createHashValue(str.constData(), str.length(), nullptr); - uint idx = hash % d->alloc; - while (1) { - if (!d->entries[idx].identifier) - return nullptr; - if (d->entries[idx].identifier->string == str) - return d->entries + idx; - ++idx; - idx %= d->alloc; - } + Identifier *id = d->identifierTable->identifier(str); + return lookup(id); } const IdentifierHashEntry *IdentifierHash::lookup(String *str) const @@ -185,6 +177,18 @@ const Identifier *IdentifierHash::toIdentifier(Heap::String *str) const return d->identifierTable->identifier(str); } +QString QV4::IdentifierHash::findId(int value) const +{ + IdentifierHashEntry *e = d->entries; + IdentifierHashEntry *end = e + d->alloc; + while (e < end) { + if (e->identifier && e->value == value) + return d->identifierTable->stringFromIdentifier(e->identifier)->toQString(); + ++e; + } + return QString(); +} + } |