summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstring.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-10-30 14:21:34 +0100
committerLars Knoll <lars.knoll@qt.io>2020-11-04 11:21:46 +0100
commitb76fbb48fba51df95d1776b8c1ff358789d78031 (patch)
tree1955e13a6498318d8d485805af1558d995924829 /src/corelib/text/qstring.h
parent419eaa0679c3867d8d9a3da8845a3015e29800d7 (diff)
Clean up out allocation handling
Get rid of the allocation options inside the flags field of QArrayData, they are really a completely separate thing. Change-Id: I823750ab9e4ca85642a0bd0e471ee79c9cde43fb Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r--src/corelib/text/qstring.h18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 66a99d4e43..013b367b5c 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -1058,7 +1058,7 @@ private:
DataPointer d;
static const char16_t _empty;
- void reallocData(qsizetype alloc, Data::ArrayOptions options);
+ void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
void reallocGrowData(qsizetype n);
static int compare_helper(const QChar *data1, qsizetype length1,
const QChar *data2, qsizetype length2,
@@ -1195,7 +1195,7 @@ inline QChar *QString::data()
inline const QChar *QString::constData() const
{ return data(); }
inline void QString::detach()
-{ if (d->needsDetach()) reallocData(d.size, d->detachFlags()); }
+{ if (d->needsDetach()) reallocData(d.size, QArrayData::KeepSize); }
inline bool QString::isDetached() const
{ return !d->isShared(); }
inline void QString::clear()
@@ -1267,22 +1267,20 @@ inline QString::~QString() {}
inline void QString::reserve(qsizetype asize)
{
- if (d->needsDetach() || asize >= capacity() - d.freeSpaceAtBegin()) {
- reallocData(qMax(asize, size()), d->detachFlags() | Data::CapacityReserved);
- } else {
+ if (d->needsDetach() || asize >= capacity() - d.freeSpaceAtBegin())
+ reallocData(qMax(asize, size()), QArrayData::KeepSize);
+ if (d->constAllocatedCapacity())
d->setFlag(Data::CapacityReserved);
- }
}
inline void QString::squeeze()
{
if (!d.isMutable())
return;
- if (d->needsDetach() || size() < capacity()) {
- reallocData(d.size, d->detachFlags() & ~Data::CapacityReserved);
- } else {
+ if (d->needsDetach() || size() < capacity())
+ reallocData(d.size, QArrayData::KeepSize);
+ if (d->constAllocatedCapacity())
d->clearFlag(Data::CapacityReserved);
- }
}
inline QString &QString::setUtf16(const ushort *autf16, qsizetype asize)