diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-12-16 09:16:57 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-09 07:47:06 +0100 |
commit | 459c9a2a8840995436e610459216957bc7ebd914 (patch) | |
tree | ef28df2fdbc62bf551088d13850492d2c6a771b1 /src/qml/jsruntime/qv4jsonobject.cpp | |
parent | 5cf95512af83fc6a0f70d3493be571accaf50d84 (diff) |
Rework array handling for JS objects
Split up ArrayData into two classes, one for regular
arrays, one for sparse arrays and cleanly separate
the two cases. Only create array data on demand.
Change-Id: I9ca8d0b53592174f213ba0f20caf93e77dba690a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 787e5300f5..65f053e92f 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -339,7 +339,7 @@ ReturnedValue JsonParser::parseArray() } } - DEBUG << "size =" << array->arrayLength(); + DEBUG << "size =" << array->getLength(); END; --nestingLevel; @@ -855,7 +855,7 @@ QString Stringify::JA(ArrayObjectRef a) indent += gap; QStringList partial; - uint len = a->arrayLength(); + uint len = a->getLength(); ScopedValue v(scope); for (uint i = 0; i < len; ++i) { bool exists; @@ -925,7 +925,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) if (o) { stringify.replacerFunction = o->asFunctionObject(); if (o->isArrayObject()) { - uint arrayLen = o->arrayLength(); + uint arrayLen = o->getLength(); ScopedValue v(scope); for (uint i = 0; i < arrayLen; ++i) { v = o->getIndexed(i); @@ -1057,9 +1057,10 @@ QV4::ReturnedValue JsonObject::fromJsonArray(ExecutionEngine *engine, const QJso int size = array.size(); Scoped<ArrayObject> a(scope, engine->newArrayObject()); a->arrayReserve(size); + ScopedValue v(scope); for (int i = 0; i < size; i++) { - a->arrayData.data[i].value = fromJsonValue(engine, array.at(i)); - a->arrayData.length = i + 1; + a->arrayData->put(i, (v = fromJsonValue(engine, array.at(i)))); + a->arrayData->setLength(i + 1); } a->setArrayLengthUnchecked(size); return a.asReturnedValue(); @@ -1083,7 +1084,7 @@ QJsonArray JsonObject::toJsonArray(ArrayObjectRef a, V4ObjectSet &visitedObjects visitedObjects.insert(a); ScopedValue v(scope); - quint32 length = a->arrayLength(); + quint32 length = a->getLength(); for (quint32 i = 0; i < length; ++i) { v = a->getIndexed(i); if (v->asFunctionObject()) |