diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-06-29 16:05:12 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-07-15 10:32:45 +0000 |
commit | 96cc0d7b4cd4de6a4a96af5a5174a4bc9bb4e5cd (patch) | |
tree | 8869954478f6eecfc1814b8632fb76943f371c67 /src/qml/jsruntime/qv4internalclass_p.h | |
parent | 0c43995e9427979fc046fe11366b44dc64ea6612 (diff) |
QML: Allow for inlining InternalClass::find
This method is used in ExecutionEngine::getProperty, which is called
quite often.
Change-Id: Ide49d158005ef1d9f51d1e734cf9e3b19f52cf26
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass_p.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index c10af4ce01..dcda949c97 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -54,6 +54,8 @@ #include <QHash> #include <private/qqmljsmemorypool_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4identifiertable_p.h> QT_BEGIN_NAMESPACE @@ -117,6 +119,20 @@ inline PropertyHash::~PropertyHash() delete d; } +inline uint PropertyHash::lookup(const Identifier *identifier) const +{ + Q_ASSERT(d->entries); + + uint idx = identifier->hashValue % d->alloc; + while (1) { + if (d->entries[idx].identifier == identifier) + return d->entries[idx].index; + if (!d->entries[idx].identifier) + return UINT_MAX; + ++idx; + idx %= d->alloc; + } +} template <typename T> struct SharedInternalClassData { @@ -245,7 +261,7 @@ struct InternalClass : public QQmlJS::Managed { InternalClass *changeMember(Identifier *identifier, PropertyAttributes data, uint *index = 0); static void changeMember(Object *object, String *string, PropertyAttributes data, uint *index = 0); static void removeMember(Object *object, Identifier *id); - uint find(const String *s); + uint find(const String *string); uint find(const Identifier *id); InternalClass *sealed(); @@ -261,6 +277,18 @@ private: InternalClass(const InternalClass &other); }; +inline uint InternalClass::find(const String *string) +{ + engine->identifierTable->identifier(string); + const Identifier *id = string->d()->identifier; + + uint index = propertyTable.lookup(id); + if (index < size) + return index; + + return UINT_MAX; +} + struct InternalClassPool : public QQmlJS::MemoryPool { void markObjects(ExecutionEngine *engine); |