diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-22 22:52:18 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-27 08:33:48 +0000 |
commit | 7fb4fc2ac7b56d3f60ceb8ae1175bd4596436cc7 (patch) | |
tree | 72f5de752001bbb8254e4d03879a5a3447767f42 /src/qml/jsruntime/qv4internalclass_p.h | |
parent | e17ab5952503595e5be3be3e492a9fb829e9877b (diff) |
Small refactoring of PropertyHash::lookup()
Change-Id: I0c8cbf0914b8de4613ab203876636746f41d9718
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass_p.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index cb45343d6d..58aca42d6e 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -79,7 +79,7 @@ struct PropertyHash PropertyHash &operator=(const PropertyHash &other); void addEntry(const Entry &entry, int classSize); - uint lookup(PropertyKey identifier) const; + Entry *lookup(PropertyKey identifier) const; int removeIdentifier(PropertyKey identifier, int classSize); void detach(bool grow, int classSize); }; @@ -126,16 +126,16 @@ inline PropertyHash &PropertyHash::operator=(const PropertyHash &other) -inline uint PropertyHash::lookup(PropertyKey identifier) const +inline PropertyHash::Entry *PropertyHash::lookup(PropertyKey identifier) const { Q_ASSERT(d->entries); uint idx = identifier.id() % d->alloc; while (1) { if (d->entries[idx].identifier == identifier) - return d->entries[idx].index; + return d->entries + idx; if (!d->entries[idx].identifier.isValid()) - return UINT_MAX; + return nullptr; ++idx; idx %= d->alloc; } @@ -352,13 +352,14 @@ struct InternalClass : Base { Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, uint *index = nullptr); static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index = nullptr); static void removeMember(QV4::Object *object, PropertyKey identifier); + uint find(const PropertyKey id) { Q_ASSERT(id.isStringOrSymbol()); - uint index = propertyTable.lookup(id); - if (index < size) - return index; + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) + return e->index; return UINT_MAX; } |