diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-01-09 11:05:08 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-20 21:14:27 +0100 |
commit | 5c25379cd1889dc16187c0ec62f32d2b17a320cf (patch) | |
tree | 23bb7bef5b2378ffe0e4193bf753811f4bf843f4 /src/qml/jsruntime/qv4property_p.h | |
parent | e2d9917878968986a9df21c9cfafc32a2360aee7 (diff) |
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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4property_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4property_p.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index 4b0896b264..6381fe7687 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -62,10 +62,10 @@ struct Property { } if (attrs->type() == PropertyAttributes::Accessor) { attrs->clearWritable(); - if (value.managed() == (Managed *)0x1) - value = Primitive::fromManaged(0); - if (set.managed() == (Managed *)0x1) - set = Primitive::fromManaged(0); + if (value.isEmpty()) + value = Primitive::undefinedValue(); + if (set.isEmpty()) + set = Primitive::undefinedValue(); } attrs->resolve(); } @@ -91,8 +91,8 @@ struct Property { inline bool isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const; inline void merge(PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs); - inline FunctionObject *getter() const { return reinterpret_cast<FunctionObject *>(value.managed()); } - inline FunctionObject *setter() const { return reinterpret_cast<FunctionObject *>(set.managed()); } + inline FunctionObject *getter() const { return reinterpret_cast<FunctionObject *>(value.asManaged()); } + inline FunctionObject *setter() const { return reinterpret_cast<FunctionObject *>(set.asManaged()); } inline void setGetter(FunctionObject *g) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(g)); } inline void setSetter(FunctionObject *s) { set = Primitive::fromManaged(reinterpret_cast<Managed *>(s)); } }; @@ -110,9 +110,9 @@ inline bool Property::isSubset(const PropertyAttributes &attrs, const Property & if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other.value)) return false; if (attrs.type() == PropertyAttributes::Accessor) { - if (value.managed() != other.value.managed()) + if (value.asManaged() != other.value.asManaged()) return false; - if (set.managed() != other.set.managed()) + if (set.asManaged() != other.set.asManaged()) return false; } return true; @@ -128,10 +128,10 @@ inline void Property::merge(PropertyAttributes &attrs, const Property &other, Pr attrs.setWritable(otherAttrs.isWritable()); if (otherAttrs.type() == PropertyAttributes::Accessor) { attrs.setType(PropertyAttributes::Accessor); - if (other.value.managed()) - value = (other.value.managed() == (Managed *)0x1) ? Primitive::fromManaged(0).asReturnedValue() : other.value.asReturnedValue(); - if (other.set.managed()) - set = (other.set.managed() == (Managed *)0x1) ? Primitive::fromManaged(0).asReturnedValue() : other.set.asReturnedValue(); + if (!other.value.isEmpty()) + value = other.value; + if (!other.set.isEmpty()) + set = other.set; } else if (otherAttrs.type() == PropertyAttributes::Data){ attrs.setType(PropertyAttributes::Data); value = other.value; |