diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-11-23 12:27:55 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2019-01-25 08:20:59 +0000 |
commit | 923fef3ad3076e337eba4e603a6f759c54cc404c (patch) | |
tree | f0430dcf1d925e6cb36a5ab5b120106c0c65b432 /src/qml/compiler | |
parent | 2a8fe8d59c80b0f3d0dfea9fb2b8526505d03e24 (diff) |
V4: Move the FixedPoolArray into the MemoryPool header
So now the FixedPoolArray can be re-used in other places.
Change-Id: I0e0504892944722a0c18f207dc6400d5b314f6ae
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 6 | ||||
-rw-r--r-- | src/qml/compiler/qqmlirbuilder_p.h | 65 | ||||
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 4 |
3 files changed, 6 insertions, 69 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index be5e0480b8..ea5efcfc66 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1630,7 +1630,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen uint nextOffset = objectOffset + objectOffsetTableSize; for (Object *o : qAsConst(output.objects)) { objectOffsets.insert(o, nextOffset); - nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.count); + nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.size()); int signalTableSize = 0; for (const Signal *s = o->firstSignal(); s; s = s->next) @@ -1705,7 +1705,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen objectToWrite->offsetToBindings = nextOffset; nextOffset += objectToWrite->nBindings * sizeof(QV4::CompiledData::Binding); - objectToWrite->nNamedObjectsInComponent = o->namedObjectsInComponent.count; + objectToWrite->nNamedObjectsInComponent = o->namedObjectsInComponent.size(); objectToWrite->offsetToNamedObjectsInComponent = nextOffset; nextOffset += objectToWrite->nNamedObjectsInComponent * sizeof(quint32); @@ -1777,7 +1777,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen } quint32_le *namedObjectInComponentPtr = reinterpret_cast<quint32_le *>(objectPtr + objectToWrite->offsetToNamedObjectsInComponent); - for (int i = 0; i < o->namedObjectsInComponent.count; ++i) { + for (int i = 0; i < o->namedObjectsInComponent.size(); ++i) { *namedObjectInComponentPtr++ = o->namedObjectsInComponent.at(i); } } diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 3dde929cc4..5dd4d1800f 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -198,69 +198,6 @@ struct PoolList Iterator end() { return Iterator(nullptr); } }; -template <typename T> -class FixedPoolArray -{ - T *data; -public: - int count = 0; - - FixedPoolArray() - : data(nullptr) - - {} - - void allocate(QQmlJS::MemoryPool *pool, int size) - { - count = size; - data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T))); - } - - void allocate(QQmlJS::MemoryPool *pool, const QVector<T> &vector) - { - count = vector.count(); - data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T))); - - if (QTypeInfo<T>::isComplex) { - for (int i = 0; i < count; ++i) - new (data + i) T(vector.at(i)); - } else { - memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T)); - } - } - - template <typename Container> - void allocate(QQmlJS::MemoryPool *pool, const Container &container) - { - count = container.count(); - data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T))); - typename Container::ConstIterator it = container.constBegin(); - for (int i = 0; i < count; ++i) - new (data + i) T(*it++); - } - - const T &at(int index) const { - Q_ASSERT(index >= 0 && index < count); - return data[index]; - } - - T &operator[](int index) { - Q_ASSERT(index >= 0 && index < count); - return data[index]; - } - - - int indexOf(const T &value) const { - for (int i = 0; i < count; ++i) - if (data[i] == value) - return i; - return -1; - } - - const T *begin() const { return data; } - const T *end() const { return data + count; } -}; - struct Object; struct EnumValue : public QV4::CompiledData::EnumValue @@ -411,7 +348,7 @@ public: FixedPoolArray<int> runtimeFunctionIndices; FixedPoolArray<quint32> namedObjectsInComponent; - int namedObjectsInComponentCount() const { return namedObjectsInComponent.count; } + int namedObjectsInComponentCount() const { return namedObjectsInComponent.size(); } const quint32 *namedObjectsInComponentTable() const { return namedObjectsInComponent.begin(); } private: diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index a03f69576d..cb097a0410 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1330,8 +1330,8 @@ bool QQmlJSCodeGenerator::compileComponent(int contextObject) } QmlIR::JSCodeGen::ObjectIdMapping idMapping; - idMapping.reserve(obj->namedObjectsInComponent.count); - for (int i = 0; i < obj->namedObjectsInComponent.count; ++i) { + idMapping.reserve(obj->namedObjectsInComponent.size()); + for (int i = 0; i < obj->namedObjectsInComponent.size(); ++i) { const int objectIndex = obj->namedObjectsInComponent.at(i); QmlIR::JSCodeGen::IdMapping m; const QmlIR::Object *obj = qmlObjects.at(objectIndex); |