diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-10-30 14:21:34 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-11-04 11:21:46 +0100 |
commit | b76fbb48fba51df95d1776b8c1ff358789d78031 (patch) | |
tree | 1955e13a6498318d8d485805af1558d995924829 /src/corelib/text/qstring.cpp | |
parent | 419eaa0679c3867d8d9a3da8845a3015e29800d7 (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.cpp')
-rw-r--r-- | src/corelib/text/qstring.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index ebdb571041..40d69c9d9c 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2415,7 +2415,7 @@ void QString::resize(qsizetype size) const auto capacityAtEnd = capacity() - d.freeSpaceAtBegin(); if (d->needsDetach() || size > capacityAtEnd) - reallocData(size, d->detachFlags() | Data::GrowsForward); + reallocData(size, QArrayData::Grow); d.size = size; if (d->allocatedCapacity()) d.data()[size] = 0; @@ -2497,7 +2497,7 @@ void QString::resize(qsizetype size, QChar fillChar) \sa reserve(), capacity() */ -void QString::reallocData(qsizetype alloc, Data::ArrayOptions allocOptions) +void QString::reallocData(qsizetype alloc, QArrayData::AllocationOption option) { if (!alloc) { d = DataPointer::fromRawData(&_empty, 0); @@ -2510,13 +2510,13 @@ void QString::reallocData(qsizetype alloc, Data::ArrayOptions allocOptions) const bool slowReallocatePath = d.freeSpaceAtBegin() > 0; if (d->needsDetach() || slowReallocatePath) { - DataPointer dd(Data::allocate(alloc, allocOptions), qMin(alloc, d.size)); + DataPointer dd(Data::allocate(alloc, option), qMin(alloc, d.size)); if (dd.size > 0) ::memcpy(dd.data(), d.data(), dd.size * sizeof(QChar)); dd.data()[dd.size] = 0; d = dd; } else { - d->reallocate(alloc, allocOptions & (QArrayData::GrowsBackwards|QArrayData::GrowsForward) ? QArrayData::Grow : QArrayData::KeepSize); + d->reallocate(alloc, option); } } @@ -2526,7 +2526,7 @@ void QString::reallocGrowData(qsizetype n) n = 1; if (d->needsDetach()) { - DataPointer dd(DataPointer::allocateGrow(d, n, DataPointer::AllocateAtEnd)); + DataPointer dd(DataPointer::allocateGrow(d, n, QArrayData::AllocateAtEnd)); dd->copyAppend(d.data(), d.data() + d.size); dd.data()[dd.size] = 0; d = dd; @@ -2737,9 +2737,9 @@ QString& QString::insert(qsizetype i, const QChar *unicode, qsizetype size) sizeToGrow += i - oldSize; if (d->needsDetach() || (sizeToGrow > d.freeSpaceAtBegin() && sizeToGrow > d.freeSpaceAtEnd())) { - DataPointer::AllocationPosition pos = DataPointer::AllocateAtEnd; + QArrayData::AllocationPosition pos = QArrayData::AllocateAtEnd; if (oldSize != 0 && i <= (oldSize >> 1)) - pos = DataPointer::AllocateAtBeginning; + pos = QArrayData::AllocateAtBeginning; DataPointer detached(DataPointer::allocateGrow(d, sizeToGrow, pos)); auto where = d.constBegin() + qMin(i, d->size); @@ -4054,7 +4054,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) if (!iterator.hasNext()) // no matches at all return *this; - reallocData(d.size, d->detachFlags()); + reallocData(d.size, QArrayData::KeepSize); qsizetype numCaptures = re.captureCount(); @@ -6157,7 +6157,7 @@ const ushort *QString::utf16() const { if (!d->isMutable()) { // ensure '\0'-termination for ::fromRawData strings - const_cast<QString*>(this)->reallocData(d.size, d->detachFlags()); + const_cast<QString*>(this)->reallocData(d.size, QArrayData::KeepSize); } return reinterpret_cast<const ushort *>(d.data()); } |