From 441a6ff47a713587f1b43c61377ed64caf15692f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 10 Apr 2014 17:17:14 +0200 Subject: Convert ObjectIterator to new data layout Change-Id: Icda43ec9c1e324afebcf632a5fdcc40d855b193d Reviewed-by: Simon Hausmann --- src/qml/jsapi/qjsvalueiterator.cpp | 10 +++++----- src/qml/jsruntime/qv4objectiterator_p.h | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp index 6dcfafaa27..f186dde630 100644 --- a/src/qml/jsapi/qjsvalueiterator.cpp +++ b/src/qml/jsapi/qjsvalueiterator.cpp @@ -108,8 +108,8 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object) return; QV4::Scope scope(v4); QV4::Scoped it(scope, d_ptr->iterator.value()); - it->it.flags = QV4::ObjectIterator::NoFlags; - it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + it->data.it.flags = QV4::ObjectIterator::NoFlags; + it->data.it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); } /*! @@ -155,7 +155,7 @@ bool QJSValueIterator::next() return false; QV4::Scope scope(v4); QV4::Scoped it(scope, d_ptr->iterator.value()); - it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + it->data.it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); return !!d_ptr->currentName || d_ptr->currentIndex != UINT_MAX; } @@ -229,8 +229,8 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object) QV4::ScopedObject o(scope, jsp->value); d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue(); QV4::Scoped it(scope, d_ptr->iterator.value()); - it->it.flags = QV4::ObjectIterator::NoFlags; - it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + it->data.it.flags = QV4::ObjectIterator::NoFlags; + it->data.it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); return *this; } diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index c87f284288..b914990ccd 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -85,14 +85,22 @@ struct Q_QML_EXPORT ObjectIterator struct ForEachIteratorObject: Object { V4_OBJECT Q_MANAGED_TYPE(ForeachIteratorObject) - ObjectIterator it; + struct Data { + Data(Value *scratch1, Value *scratch2, const ObjectRef o, uint flags) + : it(scratch1, scratch2, o, flags) {} + Data(Scope &scope, const ObjectRef o, uint flags) + : it (scope, o, flags) {} + ObjectIterator it; + }; + Data data; + ForEachIteratorObject(ExecutionContext *ctx, const ObjectRef o) - : Object(ctx->engine), it(workArea, workArea + 1, - o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { + : Object(ctx->engine), data(workArea, workArea + 1, + o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { setVTable(staticVTable()); } - ReturnedValue nextPropertyName() { return it.nextPropertyNameAsString(); } + ReturnedValue nextPropertyName() { return data.it.nextPropertyNameAsString(); } protected: static void markObjects(Managed *that, ExecutionEngine *e); -- cgit v1.2.3