summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydata.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-10-30 14:10:31 +0100
committerLars Knoll <lars.knoll@qt.io>2020-11-04 11:21:41 +0100
commit419eaa0679c3867d8d9a3da8845a3015e29800d7 (patch)
treebf867e2c1dfcf1a53d750261c8da3016d4db5093 /src/corelib/tools/qarraydata.h
parent32a703e2779e697a9a7d75f6cbc6e555187d7fca (diff)
Cleanup QArrayDataOps::reallocate() and related
Don't use QArrayData::GrowsForward/Backward anymore and replace it with a simple 'bool grow'. Change-Id: Ifddfef3ae860b11dda4c40854c71ef2aeb29df34 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
-rw-r--r--src/corelib/tools/qarraydata.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 4cb0f7a45c..76f2c33043 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -51,6 +51,11 @@ template <class T> struct QTypedArrayData;
struct Q_CORE_EXPORT QArrayData
{
+ enum AllocationOption {
+ Grow,
+ KeepSize
+ };
+
enum ArrayOption {
/// this option is used by the allocate() function
DefaultAllocationFlags = 0,
@@ -122,7 +127,7 @@ struct Q_CORE_EXPORT QArrayData
static void *allocate(QArrayData **pdata, qsizetype objectSize, qsizetype alignment,
qsizetype capacity, ArrayOptions options = DefaultAllocationFlags) noexcept;
[[nodiscard]] static QPair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer,
- qsizetype objectSize, qsizetype newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept;
+ qsizetype objectSize, qsizetype newCapacity, AllocationOption option) noexcept;
static void deallocate(QArrayData *data, qsizetype objectSize,
qsizetype alignment) noexcept;
};
@@ -221,12 +226,11 @@ struct QTypedArrayData
}
static QPair<QTypedArrayData *, T *>
- reallocateUnaligned(QTypedArrayData *data, T *dataPointer, qsizetype capacity,
- ArrayOptions options = DefaultAllocationFlags)
+ reallocateUnaligned(QTypedArrayData *data, T *dataPointer, qsizetype capacity, AllocationOption option)
{
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
QPair<QArrayData *, void *> pair =
- QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, options);
+ QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, option);
return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second));
}