diff options
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 6d78c89d89..1b2532018e 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -533,7 +533,8 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint while (it->arrayNode != o->sparseEnd()) { int k = it->arrayNode->key(); uint pidx = it->arrayNode->value; - Property *p = reinterpret_cast<Property *>(o->arrayData()->arrayData() + pidx); + SparseArrayData *sa = static_cast<SparseArrayData *>(o->arrayData()); + Property *p = reinterpret_cast<Property *>(sa->arrayData() + pidx); it->arrayNode = it->arrayNode->nextNode(); PropertyAttributes a = o->arrayData()->attributes(k); if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) { @@ -549,14 +550,15 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint } // dense arrays while (it->arrayIndex < o->arrayData()->length()) { - Value *val = o->arrayData()->arrayData() + it->arrayIndex; + SimpleArrayData *sa = static_cast<SimpleArrayData *>(o->arrayData()); + Value &val = sa->data(it->arrayIndex); PropertyAttributes a = o->arrayData()->attributes(it->arrayIndex); ++it->arrayIndex; - if (!val->isEmpty() + if (!val.isEmpty() && (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable())) { *index = it->arrayIndex - 1; *attrs = a; - pd->value = *val; + pd->value = val; return; } } @@ -1073,14 +1075,15 @@ void Object::copyArrayData(Object *other) } else if (other->hasAccessorProperty() && other->arrayData()->attrs() && other->arrayData()->isSparse()){ // do it the slow way ScopedValue v(scope); - for (const SparseArrayNode *it = static_cast<const SparseArrayData *>(other->arrayData())->sparse()->begin(); - it != static_cast<const SparseArrayData *>(other->arrayData())->sparse()->end(); it = it->nextNode()) { - v = other->getValue(reinterpret_cast<Property *>(other->arrayData()->arrayData() + it->value), other->arrayData()->attrs()[it->value]); + const SparseArrayData *osa = static_cast<const SparseArrayData *>(other->arrayData()); + for (const SparseArrayNode *it = osa->sparse()->begin(); + it != osa->sparse()->end(); it = it->nextNode()) { + v = other->getValue(reinterpret_cast<Property *>(osa->arrayData() + it->value), other->arrayData()->attrs()[it->value]); arraySet(it->key(), v); } } else { Q_ASSERT(!arrayData() && other->arrayData()); - ArrayData::realloc(this, other->arrayData()->type(), 0, other->arrayData()->alloc(), other->arrayData()->attrs()); + ArrayData::realloc(this, other->arrayData()->type(), other->arrayData()->alloc(), false); if (other->arrayType() == ArrayData::Sparse) { SparseArrayData *od = static_cast<SparseArrayData *>(other->arrayData()); SparseArrayData *dd = static_cast<SparseArrayData *>(arrayData()); @@ -1089,9 +1092,9 @@ void Object::copyArrayData(Object *other) } else { SimpleArrayData *d = static_cast<SimpleArrayData *>(arrayData()); d->len() = static_cast<SimpleArrayData *>(other->arrayData())->len(); - d->offset() = 0; + d->d()->offset = static_cast<SimpleArrayData *>(other->arrayData())->d()->offset; } - memcpy(arrayData()->arrayData(), other->arrayData()->arrayData(), arrayData()->alloc()*sizeof(Value)); + memcpy(arrayData()->d()->arrayData, other->arrayData()->d()->arrayData, arrayData()->alloc()*sizeof(Value)); } setArrayLengthUnchecked(other->getLength()); } @@ -1132,7 +1135,7 @@ void Object::initSparseArray() if (arrayType() == ArrayData::Sparse) return; - ArrayData::realloc(this, ArrayData::Sparse, 0, 0, false); + ArrayData::realloc(this, ArrayData::Sparse, 0, false); } |