aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-01-08 13:08:41 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-20 21:13:48 +0100
commita7431e41128bd3aa272223746a5bb57597a87de3 (patch)
treee5308d5fed3474badba313179f2f1891df300bac /src/qml/jsapi
parent50d6e51c73a37858699b90d64657cec5e0b53610 (diff)
Remove Property * return value from ObjectIterator
The added side effect is that the QJSValueIterator is now somewhat faster. Change-Id: I01ba9f2a72a34224f5691130df69a91ab75b72e6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp27
-rw-r--r--src/qml/jsapi/qjsvalueiterator_p.h2
2 files changed, 12 insertions, 17 deletions
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index ed011ef691..e3358b29bd 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -109,7 +109,7 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object)
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->it.flags = QV4::ObjectIterator::NoFlags;
- it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
+ it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
}
/*!
@@ -150,6 +150,7 @@ bool QJSValueIterator::next()
return false;
d_ptr->currentName = d_ptr->nextName;
d_ptr->currentIndex = d_ptr->nextIndex;
+ d_ptr->currentProperty = d_ptr->nextProperty;
d_ptr->currentAttributes = d_ptr->nextAttributes;
QV4::ExecutionEngine *v4 = d_ptr->iterator.engine();
@@ -157,7 +158,7 @@ bool QJSValueIterator::next()
return false;
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
+ it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
return !!d_ptr->nextName || d_ptr->nextIndex != UINT_MAX;
}
@@ -187,27 +188,19 @@ QString QJSValueIterator::name() const
*/
QJSValue QJSValueIterator::value() const
{
- if (!QJSValuePrivate::get(d_ptr->value)->value.isObject())
- return QJSValue();
-
QV4::ExecutionEngine *engine = d_ptr->iterator.engine();
if (!engine)
return QJSValue();
-
QV4::Scope scope(engine);
- QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- QV4::ScopedObject o(scope, it->it.object);
+ QV4::ScopedObject obj(scope, QJSValuePrivate::get(d_ptr->value)->value);
+ if (!obj)
+ return QJSValue();
QV4::ExecutionContext *ctx = engine->currentContext();
- QV4::ScopedValue v(scope);
- if (!!d_ptr->currentName) {
- QV4::ScopedString n(scope, d_ptr->currentName);
- v = o->get(n);
- } else if (d_ptr->currentIndex != UINT_MAX) {
- v = o->getIndexed(d_ptr->currentIndex);
- } else {
+ if (!d_ptr->currentName && d_ptr->currentIndex == UINT_MAX)
return QJSValue();
- }
+
+ QV4::ScopedValue v(scope, obj->getValue(obj, &d_ptr->currentProperty, d_ptr->currentAttributes));
if (scope.hasException()) {
ctx->catchException();
return QJSValue();
@@ -240,7 +233,7 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object)
d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue();
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->it.flags = QV4::ObjectIterator::NoFlags;
- it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
+ it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
return *this;
}
diff --git a/src/qml/jsapi/qjsvalueiterator_p.h b/src/qml/jsapi/qjsvalueiterator_p.h
index b7a9b4a190..80d1885811 100644
--- a/src/qml/jsapi/qjsvalueiterator_p.h
+++ b/src/qml/jsapi/qjsvalueiterator_p.h
@@ -56,9 +56,11 @@ public:
QJSValue value;
QV4::PersistentValue iterator;
+ QV4::Property currentProperty;
QV4::PropertyAttributes currentAttributes;
QV4::SafeString currentName;
uint currentIndex;
+ QV4::Property nextProperty;
QV4::PropertyAttributes nextAttributes;
QV4::SafeString nextName;
uint nextIndex;