diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-23 22:25:53 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-02 19:29:40 +0000 |
commit | 86f88521fbea59e8ec53e50cc1e3e68a61f53c40 (patch) | |
tree | 25f72eaf70639409d3c8a8469a05b7be0a0da03b /src/qml/jsruntime/qv4identifier.cpp | |
parent | 8728a2b494eb384b65bd4e7c6ec785435a37de9d (diff) |
Replace Identifier by PropertyKey
Change all uses of Identifier to use the new PropertyKey class
and get rid of Identifier.
Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4identifier.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4identifier.cpp | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index 1e9a807848..fb2e9c29c2 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -44,33 +44,6 @@ QT_BEGIN_NAMESPACE namespace QV4 { -bool Identifier::isString() const -{ - return isStringOrSymbol() && asStringOrSymbol()->internalClass->vtable->isString; -} - -bool Identifier::isSymbol() const -{ - return isStringOrSymbol() && !asStringOrSymbol()->internalClass->vtable->isString && asStringOrSymbol()->internalClass->vtable->isStringOrSymbol; -} - -Heap::StringOrSymbol *Identifier::toStringOrSymbol(ExecutionEngine *e) -{ - if (isArrayIndex()) - return Primitive::fromUInt32(asArrayIndex()).toString(e); - return static_cast<Heap::StringOrSymbol *>(asStringOrSymbol()); -} - -QString Identifier::toQString() const -{ - if (isArrayIndex()) - return QString::number(asArrayIndex()); - Heap::Base *b = asStringOrSymbol(); - Q_ASSERT(b->internalClass->vtable->isStringOrSymbol); - Heap::StringOrSymbol *s = static_cast<Heap::StringOrSymbol *>(b); - return s->toQString(); -} - static const uchar prime_deltas[] = { 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3, 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0 @@ -128,7 +101,7 @@ void IdentifierHash::detach() } -IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) +IdentifierHashEntry *IdentifierHash::addEntry(PropertyKey identifier) { Q_ASSERT(identifier.isStringOrSymbol()); @@ -144,7 +117,7 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) const IdentifierHashEntry &e = d->entries[i]; if (!e.identifier.isValid()) continue; - uint idx = e.identifier.id % newAlloc; + uint idx = e.identifier.id() % newAlloc; while (newEntries[idx].identifier.isValid()) { ++idx; idx %= newAlloc; @@ -156,7 +129,7 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) d->alloc = newAlloc; } - uint idx = identifier.id % d->alloc; + uint idx = identifier.id() % d->alloc; while (d->entries[idx].identifier.isValid()) { Q_ASSERT(d->entries[idx].identifier != identifier); ++idx; @@ -167,13 +140,13 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) return d->entries + idx; } -const IdentifierHashEntry *IdentifierHash::lookup(Identifier identifier) const +const IdentifierHashEntry *IdentifierHash::lookup(PropertyKey identifier) const { if (!d || !identifier.isStringOrSymbol()) return nullptr; Q_ASSERT(d->entries); - uint idx = identifier.id % d->alloc; + uint idx = identifier.id() % d->alloc; while (1) { if (!d->entries[idx].identifier.isValid()) return nullptr; @@ -189,7 +162,7 @@ const IdentifierHashEntry *IdentifierHash::lookup(const QString &str) const if (!d) return nullptr; - Identifier id = d->identifierTable->identifier(str); + PropertyKey id = d->identifierTable->identifier(str); return lookup(id); } @@ -197,19 +170,19 @@ const IdentifierHashEntry *IdentifierHash::lookup(String *str) const { if (!d) return nullptr; - Identifier id = d->identifierTable->identifier(str); + PropertyKey id = d->identifierTable->identifier(str); if (id.isValid()) return lookup(id); return lookup(str->toQString()); } -const Identifier IdentifierHash::toIdentifier(const QString &str) const +const PropertyKey IdentifierHash::toIdentifier(const QString &str) const { Q_ASSERT(d); return d->identifierTable->identifier(str); } -const Identifier IdentifierHash::toIdentifier(Heap::String *str) const +const PropertyKey IdentifierHash::toIdentifier(Heap::String *str) const { Q_ASSERT(d); return d->identifierTable->identifier(str); |