aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-05-16 15:03:39 +0200
committerLars Knoll <lars.knoll@qt.io>2017-05-19 06:23:35 +0000
commitc03eedaf8c6846dc80ab014face4d514deb9665d (patch)
treeb5d20849a9b3536bab01625dabb61583c6366490 /src/qml/jsruntime/qv4object.cpp
parent10b237882cfe76521b4dc65300a2a0473faca174 (diff)
Optimize lookups in the internalClass
Inline the version taking an identifier, and use that one where it makes sense. Change-Id: I414c5999e61cdba219ecd1080957f3037dfebc1b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r--src/qml/jsruntime/qv4object.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index c3ebb53622..cac9d8ad7d 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -294,7 +294,10 @@ void Object::getOwnProperty(String *name, PropertyAttributes *attrs, Property *p
if (idx != UINT_MAX)
return getOwnProperty(idx, attrs, p);
- uint member = internalClass()->find(name);
+ name->makeIdentifier(engine());
+ Identifier *id = name->identifier();
+
+ uint member = internalClass()->find(id);
if (member < UINT_MAX) {
*attrs = internalClass()->propertyData[member];
if (p) {
@@ -336,9 +339,12 @@ Value *Object::getValueOrSetter(String *name, PropertyAttributes *attrs)
{
Q_ASSERT(name->asArrayIndex() == UINT_MAX);
+ name->makeIdentifier(engine());
+ Identifier *id = name->identifier();
+
Heap::Object *o = d();
while (o) {
- uint idx = o->internalClass->find(name);
+ uint idx = o->internalClass->find(id);
if (idx < UINT_MAX) {
*attrs = o->internalClass->propertyData[idx];
return o->propertyData(attrs->isAccessor() ? idx + SetterOffset : idx);
@@ -411,7 +417,10 @@ bool Object::hasOwnProperty(String *name) const
if (idx != UINT_MAX)
return hasOwnProperty(idx);
- if (internalClass()->find(name) < UINT_MAX)
+ name->makeIdentifier(engine());
+ Identifier *id = name->identifier();
+
+ if (internalClass()->find(id) < UINT_MAX)
return true;
if (!query(name).isEmpty())
return true;
@@ -468,8 +477,11 @@ PropertyAttributes Object::query(const Managed *m, String *name)
if (idx != UINT_MAX)
return queryIndexed(m, idx);
+ name->makeIdentifier(m->internalClass()->engine);
+ Identifier *id = name->identifier();
+
const Object *o = static_cast<const Object *>(m);
- idx = o->internalClass()->find(name);
+ idx = o->internalClass()->find(id);
if (idx < UINT_MAX)
return o->internalClass()->propertyData[idx];
@@ -670,10 +682,11 @@ ReturnedValue Object::internalGet(String *name, bool *hasProperty) const
Scope scope(engine());
name->makeIdentifier(scope.engine);
+ Identifier *id = name->identifier();
ScopedObject o(scope, this);
while (o) {
- uint idx = o->internalClass()->find(name);
+ uint idx = o->internalClass()->find(id);
if (idx < UINT_MAX) {
if (hasProperty)
*hasProperty = true;
@@ -736,8 +749,9 @@ void Object::internalPut(String *name, const Value &value)
return putIndexed(idx, value);
name->makeIdentifier(engine());
+ Identifier *id = name->identifier();
- uint member = internalClass()->find(name);
+ uint member = internalClass()->find(id);
Value *v = 0;
PropertyAttributes attrs;
if (member < UINT_MAX) {
@@ -890,7 +904,7 @@ bool Object::internalDeleteProperty(String *name)
name->makeIdentifier(engine());
- uint memberIdx = internalClass()->find(name);
+ uint memberIdx = internalClass()->find(name->identifier());
if (memberIdx != UINT_MAX) {
if (internalClass()->propertyData[memberIdx].isConfigurable()) {
InternalClass::removeMember(this, name->identifier());
@@ -961,7 +975,7 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const
}
// Clause 1
- memberIndex = internalClass()->find(name);
+ memberIndex = internalClass()->find(name->identifier());
if (memberIndex == UINT_MAX) {
// clause 3