diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-04-10 17:53:00 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-07-22 13:48:58 +0200 |
commit | 43df154aa1d3347d81d8c6eba09871da318c417e (patch) | |
tree | e41d7ff94dfa4c8a5292e3bfbc30b80afa225d39 /src/qml/jsruntime/qv4arraydata_p.h | |
parent | f05f3a36b43ada6b37cda1ee4703fe857f8771da (diff) |
Move ArrayData over to new data layout
Change-Id: Ic51f37bea030b196f0fa35ab21e618447edaa25d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4arraydata_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4arraydata_p.h | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index eef3816ef6..a5524da4f9 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -92,13 +92,27 @@ struct Q_QML_EXPORT ArrayData : public Managed Custom = 3 }; - uint alloc; - Type type; - PropertyAttributes *attrs; - Value *data; + struct Data { + uint alloc; + Type type; + PropertyAttributes *attrs; + Value *arrayData; + }; + Data data; + + uint alloc() const { return data.alloc; } + uint &alloc() { return data.alloc; } + void setAlloc(uint a) { data.alloc = a; } + Type type() const { return data.type; } + void setType(Type t) { data.type = t; } + PropertyAttributes *attrs() const { return data.attrs; } + void setAttrs(PropertyAttributes *a) { data.attrs = a; } + Value *arrayData() const { return data.arrayData; } + Value *&arrayData() { return data.arrayData; } + void setArrayData(Value *v) { data.arrayData = v; } const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(internalClass()->vtable); } - bool isSparse() const { return this && type == Sparse; } + bool isSparse() const { return this && type() == Sparse; } uint length() const { if (!this) @@ -107,11 +121,11 @@ struct Q_QML_EXPORT ArrayData : public Managed } bool hasAttributes() const { - return this && attrs; + return this && attrs(); } PropertyAttributes attributes(int i) const { Q_ASSERT(this); - return attrs ? vtable()->attribute(this, i) : Attr_Data; + return attrs() ? vtable()->attribute(this, i) : Attr_Data; } bool isEmpty(uint i) const { @@ -143,8 +157,16 @@ struct Q_QML_EXPORT SimpleArrayData : public ArrayData : ArrayData(engine->simpleArrayDataClass) {} - uint len; - uint offset; + struct Data { + uint len; + uint offset; + }; + Data data; + + uint &len() { return data.len; } + uint len() const { return data.len; } + uint &offset() { return data.offset; } + uint offset() const { return data.offset; } static void getHeadRoom(Object *o); static ArrayData *reallocate(Object *o, uint n, bool enforceAttributes); @@ -171,8 +193,16 @@ struct Q_QML_EXPORT SparseArrayData : public ArrayData : ArrayData(engine->emptyClass) { setVTable(staticVTable()); } - uint freeList; - SparseArray *sparse; + struct Data { + uint freeList; + SparseArray *sparse; + }; + Data data; + + uint &freeList() { return data.freeList; } + uint freeList() const { return data.freeList; } + SparseArray *sparse() const { return data.sparse; } + void setSparse(SparseArray *s) { data.sparse = s; } static uint allocate(Object *o, bool doubleSlot = false); static void free(ArrayData *d, uint idx); @@ -198,16 +228,16 @@ inline Property *ArrayData::getProperty(uint index) const { if (!this) return 0; - if (type != Sparse) { + if (type() != Sparse) { const SimpleArrayData *that = static_cast<const SimpleArrayData *>(this); - if (index >= that->len || data[index].isEmpty()) + if (index >= that->len() || arrayData()[index].isEmpty()) return 0; - return reinterpret_cast<Property *>(data + index); + return reinterpret_cast<Property *>(arrayData() + index); } else { - SparseArrayNode *n = static_cast<const SparseArrayData *>(this)->sparse->findNode(index); + SparseArrayNode *n = static_cast<const SparseArrayData *>(this)->sparse()->findNode(index); if (!n) return 0; - return reinterpret_cast<Property *>(data + n->value); + return reinterpret_cast<Property *>(arrayData() + n->value); } } |