aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-11-23 12:27:55 +0100
committerErik Verbruggen <erik.verbruggen@qt.io>2019-01-25 08:20:59 +0000
commit923fef3ad3076e337eba4e603a6f759c54cc404c (patch)
treef0430dcf1d925e6cb36a5ab5b120106c0c65b432 /src/qml/compiler/qqmlirbuilder_p.h
parent2a8fe8d59c80b0f3d0dfea9fb2b8526505d03e24 (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/qqmlirbuilder_p.h')
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h65
1 files changed, 1 insertions, 64 deletions
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: