diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-01-13 09:09:14 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-20 21:14:31 +0100 |
commit | bf6191f090b326eb0776cd4e921ddb56c8daa8a9 (patch) | |
tree | 7e0b3084366aa35542f591d2ffcc0dc0c70efe75 /src/qml/jsruntime/qv4runtime.cpp | |
parent | 5c25379cd1889dc16187c0ec62f32d2b17a320cf (diff) |
Add a SimpleArrayData class
This makes the ArrayData class 'pure virtual'. SimpleArrayData
now contains the implementation of simple arrays. This makes the
separation between simple and sparse arrays a lot cleaner.
It also allows us to move len and offset from the base class into
the SimpleArrayClass. This fixes some bugs where we accessed len
for sparse arrays leading to some buggy behavior.
Added a virtual length() method to ArrayData to query the highes
used index in the Array.
Change-Id: Iab2ba2a48ebe5b7031759eeb4ebe02b4d86233f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index a8b453309d..2f1b8a0bd3 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -613,7 +613,7 @@ void __qmljs_set_element(ExecutionContext *ctx, const ValueRef object, const Val uint idx = index->asArrayIndex(); if (idx < UINT_MAX) { - if (idx < o->arrayData->length() && o->arrayType() == ArrayData::Simple) + if (o->arrayType() == ArrayData::Simple && idx < o->arrayData->length()) o->arrayData->put(idx, value); else o->putIndexed(idx, value); @@ -1105,7 +1105,6 @@ ReturnedValue __qmljs_builtin_define_array(ExecutionContext *ctx, SafeValue *val if (length) { a->arrayReserve(length); - a->arrayData->setLength(length); a->arrayData->put(0, values, length); a->setArrayLengthUnchecked(length); } |