summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2019-12-02 16:06:48 +0100
committerLars Knoll <lars.knoll@qt.io>2020-07-06 21:30:19 +0200
commitf8a53388a78ba70ed609df8738db9bc75e99af86 (patch)
treedbab9ac59121cd18e246d751690b63805789a6db /src/corelib/tools
parenta8d5f3853741b6027658ad2c8a8d2b72a58de852 (diff)
Get rid of unused flags in QArrayData
Change-Id: I3ea754b44fb33e33baba0781d9ae15b7f3b3d8eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qarraydata.cpp9
-rw-r--r--src/corelib/tools/qarraydata.h23
2 files changed, 8 insertions, 24 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index 9330a01a87..42599bbf2a 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -153,11 +153,11 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
const QArrayData QArrayData::shared_null[2] = {
- { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }, // shared null
+ { Q_BASIC_ATOMIC_INITIALIZER(-1), 0, 0 }, // shared null
/* zero initialized terminator */};
static const QArrayData emptyNotNullShared[2] = {
- { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }, // shared empty
+ { Q_BASIC_ATOMIC_INITIALIZER(-1), 0, 0 }, // shared empty
/* zero initialized terminator */};
QT_WARNING_POP
@@ -217,8 +217,6 @@ void *QArrayData::allocate(QArrayData **dptr, size_t objectSize, size_t alignmen
return nullptr;
size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options);
- options |= AllocatedDataType | MutableData;
- options &= ~ImmutableHeader;
QArrayData *header = allocateData(allocSize, options);
quintptr data = 0;
if (header) {
@@ -241,7 +239,6 @@ QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer,
size_t headerSize = sizeof(QArrayData);
size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options);
qptrdiff offset = dataPointer ? reinterpret_cast<char *>(dataPointer) - reinterpret_cast<char *>(data) : headerSize;
- options |= AllocatedDataType | MutableData;
QArrayData *header = static_cast<QArrayData *>(::realloc(data, size_t(allocSize)));
if (header) {
header->flags = options;
@@ -260,8 +257,6 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize,
Q_UNUSED(objectSize);
Q_UNUSED(alignment);
- Q_ASSERT_X(data == nullptr || !data->isStatic(), "QArrayData::deallocate",
- "Static data cannot be deleted");
::free(data);
}
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index c921e4eaa5..7624f7ad20 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -52,22 +52,11 @@ template <class T> struct QTypedArrayData;
struct Q_CORE_EXPORT QArrayData
{
enum ArrayOption {
- RawDataType = 0x0001, //!< this class is really a QArrayData
- AllocatedDataType = 0x0002, //!< this class is really a QArrayAllocatedData
- DataTypeBits = 0x000f,
-
- CapacityReserved = 0x0010, //!< the capacity was reserved by the user, try to keep it
- GrowsForward = 0x0020, //!< allocate with eyes towards growing through append()
- GrowsBackwards = 0x0040, //!< allocate with eyes towards growing through prepend()
- MutableData = 0x0080, //!< the data can be changed; doesn't say anything about the header
- ImmutableHeader = 0x0100, //!< the header is static, it can't be changed
-
- /// this option is used by the Q_ARRAY_LITERAL and similar macros
- StaticDataFlags = RawDataType | ImmutableHeader,
/// this option is used by the allocate() function
- DefaultAllocationFlags = MutableData,
- /// this option is used by the prepareRawData() function
- DefaultRawFlags = 0
+ DefaultAllocationFlags = 0,
+ CapacityReserved = 0x1, //!< the capacity was reserved by the user, try to keep it
+ GrowsForward = 0x2, //!< allocate with eyes towards growing through append()
+ GrowsBackwards = 0x4 //!< allocate with eyes towards growing through prepend()
};
Q_DECLARE_FLAGS(ArrayOptions, ArrayOption)
@@ -106,12 +95,12 @@ struct Q_CORE_EXPORT QArrayData
// follow COW principles.
bool isMutable() const
{
- return flags & MutableData;
+ return ref_.loadRelaxed() != -1;
}
bool isStatic() const
{
- return flags & ImmutableHeader;
+ return !isMutable();
}
bool isShared() const