From 5c25379cd1889dc16187c0ec62f32d2b17a320cf Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 9 Jan 2014 11:05:08 +0100 Subject: Save memory on array data Store a simple vector of Values in the array data, instead of a Vector of Property's. This halfes the memory consumption on 64bit and simplifies our code. If an indexed property gets converted to an accessor property, we simply convert the ArrayData into a SparseArrayData. Add support in SparseArrayData to allocate double slots (two Value's) to hold a full Property in case someone sets an accessor on an indexed property. Some methods still return a Property*, but this is safe, as only the first Value in the Property pointer will ever get accessed if the Property doesn't contain an accessor. Change-Id: Ic9b0f309b09a2772a328d947a10faaf3be9fe56f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4sparsearray.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/qml/jsruntime/qv4sparsearray.cpp') diff --git a/src/qml/jsruntime/qv4sparsearray.cpp b/src/qml/jsruntime/qv4sparsearray.cpp index 97dd695067..7169f5c20e 100644 --- a/src/qml/jsruntime/qv4sparsearray.cpp +++ b/src/qml/jsruntime/qv4sparsearray.cpp @@ -53,13 +53,13 @@ using namespace QV4; -bool ArrayElementLessThan::operator()(const Property &p1, const Property &p2) const +bool ArrayElementLessThan::operator()(const SafeValue &v1, const SafeValue &v2) const { Scope scope(m_context); - if (p1.value.isUndefined() || p1.value.isEmpty()) + if (v1.isUndefined() || v1.isEmpty()) return false; - if (p2.value.isUndefined() || p2.value.isEmpty()) + if (v2.isUndefined() || v2.isEmpty()) return true; ScopedObject o(scope, m_comparefn); if (o) { @@ -67,14 +67,14 @@ bool ArrayElementLessThan::operator()(const Property &p1, const Property &p2) co ScopedValue result(scope); ScopedCallData callData(scope, 2); callData->thisObject = Primitive::undefinedValue(); - callData->args[0] = p1.value; - callData->args[1] = p2.value; + callData->args[0] = v1; + callData->args[1] = v2; result = __qmljs_call_value(m_context, m_comparefn, callData); return result->toNumber() < 0; } - ScopedString p1s(scope, p1.value.toString(m_context)); - ScopedString p2s(scope, p2.value.toString(m_context)); + ScopedString p1s(scope, v1.toString(m_context)); + ScopedString p2s(scope, v2.toString(m_context)); return p1s->toQString() < p2s->toQString(); } -- cgit v1.2.3