From bf6191f090b326eb0776cd4e921ddb56c8daa8a9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 13 Jan 2014 09:09:14 +0100 Subject: 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 --- src/qml/jsruntime/qv4runtime.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/qml/jsruntime/qv4runtime.cpp') 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); } -- cgit v1.2.3