summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-11-02 10:18:59 +0100
committerThiago Macieira <thiago.macieira@intel.com>2020-11-04 10:22:16 +0000
commit1282c05cdcc935a5eb1be150b8fd88f7771e81de (patch)
tree584ba75a2dcd63b77d3183e7229e634325e57d2e /src
parentedd1e931d1f0a1c5f9b2c1869d34db577307605d (diff)
Rename AllocationPosition enum and its members
Use GrowsAt* and GrowthPosition as that is clearer. Change-Id: I3c173797dec3620f508156efc0c51b4d2cd3e142 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/text/qbytearray.cpp6
-rw-r--r--src/corelib/text/qstring.cpp4
-rw-r--r--src/corelib/tools/qarraydata.h6
-rw-r--r--src/corelib/tools/qarraydataops.h8
-rw-r--r--src/corelib/tools/qarraydatapointer.h10
-rw-r--r--src/corelib/tools/qlist.h12
6 files changed, 23 insertions, 23 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index d729667ff7..f4ade684a0 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1730,7 +1730,7 @@ void QByteArray::reallocGrowData(qsizetype n)
n = 1;
if (d->needsDetach()) {
- DataPointer dd(DataPointer::allocateGrow(d, n, QArrayData::AllocateAtEnd));
+ DataPointer dd(DataPointer::allocateGrow(d, n, QArrayData::GrowsAtEnd));
dd->copyAppend(d.data(), d.data() + d.size);
dd.data()[dd.size] = 0;
d = dd;
@@ -1934,7 +1934,7 @@ QByteArray &QByteArray::insert(qsizetype i, QByteArrayView data)
// the old memory:
DataPointer detached{}; // construction is free
if (d->needsDetach() || i + size - d->size > d.freeSpaceAtEnd()) {
- detached = DataPointer::allocateGrow(d, i + size - d->size, Data::AllocateAtEnd);
+ detached = DataPointer::allocateGrow(d, i + size - d->size, Data::GrowsAtEnd);
detached->copyAppend(d.constBegin(), d.constEnd());
d.swap(detached);
}
@@ -1993,7 +1993,7 @@ QByteArray &QByteArray::insert(qsizetype i, qsizetype count, char ch)
if (i >= d->size) {
// handle this specially, as QArrayDataOps::insert() doesn't handle out of bounds positions
if (d->needsDetach() || i + count - d->size > d.freeSpaceAtEnd()) {
- DataPointer detached(DataPointer::allocateGrow(d, i + count - d->size, Data::AllocateAtEnd));
+ DataPointer detached(DataPointer::allocateGrow(d, i + count - d->size, Data::GrowsAtEnd));
detached->copyAppend(d.constBegin(), d.constEnd());
d.swap(detached);
}
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 6e7809d868..1f32c4db7d 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -2526,7 +2526,7 @@ void QString::reallocGrowData(qsizetype n)
n = 1;
if (d->needsDetach()) {
- DataPointer dd(DataPointer::allocateGrow(d, n, QArrayData::AllocateAtEnd));
+ DataPointer dd(DataPointer::allocateGrow(d, n, QArrayData::GrowsAtEnd));
dd->copyAppend(d.data(), d.data() + d.size);
dd.data()[dd.size] = 0;
d = dd;
@@ -2737,7 +2737,7 @@ QString& QString::insert(qsizetype i, const QChar *unicode, qsizetype size)
// the old memory:
DataPointer detached{}; // construction is free
if (d->needsDetach() || i + size - d->size > d.freeSpaceAtEnd()) {
- detached = DataPointer::allocateGrow(d, i + size - d->size, Data::AllocateAtEnd);
+ detached = DataPointer::allocateGrow(d, i + size - d->size, Data::GrowsAtEnd);
detached->copyAppend(d.constBegin(), d.constEnd());
d.swap(detached);
}
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 9ada91d04b..7c91ceee47 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -56,9 +56,9 @@ struct Q_CORE_EXPORT QArrayData
KeepSize
};
- enum AllocationPosition {
- AllocateAtEnd,
- AllocateAtBeginning
+ enum GrowthPosition {
+ GrowsAtEnd,
+ GrowsAtBeginning
};
enum ArrayOption {
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index d8508b22a8..12d30e6d5d 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -1185,9 +1185,9 @@ public:
void insert(qsizetype i, qsizetype n, parameter_type t)
{
if (this->needsDetach() || (n > this->freeSpaceAtBegin() && n > this->freeSpaceAtEnd())) {
- typename Data::AllocationPosition pos = Data::AllocateAtEnd;
+ typename Data::GrowthPosition pos = Data::GrowsAtEnd;
if (this->size != 0 && i <= (this->size >> 1))
- pos = Data::AllocateAtBeginning;
+ pos = Data::GrowsAtBeginning;
DataPointer detached(DataPointer::allocateGrow(*this, n, pos));
const_iterator where = this->constBegin() + i;
@@ -1219,9 +1219,9 @@ public:
void insert(qsizetype i, const T *data, qsizetype n)
{
if (this->needsDetach() || (n > this->freeSpaceAtBegin() && n > this->freeSpaceAtEnd())) {
- typename Data::AllocationPosition pos = Data::AllocateAtEnd;
+ typename Data::GrowthPosition pos = Data::GrowsAtEnd;
if (this->size != 0 && i <= (this->size >> 1))
- pos = Data::AllocateAtBeginning;
+ pos = Data::GrowsAtBeginning;
DataPointer detached(DataPointer::allocateGrow(*this, n, pos));
auto where = this->constBegin() + i;
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index 20015cbadd..f6e556597f 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -207,7 +207,7 @@ public:
}
// allocate and grow. Ensure that at the minimum requiredSpace is available at the requested end
- static QArrayDataPointer allocateGrow(const QArrayDataPointer &from, qsizetype n, QArrayData::AllocationPosition position)
+ static QArrayDataPointer allocateGrow(const QArrayDataPointer &from, qsizetype n, QArrayData::GrowthPosition position)
{
// calculate new capacity. We keep the free capacity at the side that does not have to grow
// to avoid quadratic behavior with mixed append/prepend cases
@@ -216,7 +216,7 @@ public:
qsizetype minimalCapacity = qMax(from.size, from.constAllocatedCapacity()) + n;
// subtract the free space at the side we want to allocate. This ensures that the total size requested is
// the existing allocation at the other side + size + n.
- minimalCapacity -= (position == QArrayData::AllocateAtEnd) ? from.freeSpaceAtEnd() : from.freeSpaceAtBegin();
+ minimalCapacity -= (position == QArrayData::GrowsAtEnd) ? from.freeSpaceAtEnd() : from.freeSpaceAtBegin();
qsizetype capacity = from.detachCapacity(minimalCapacity);
const bool grows = capacity > from.constAllocatedCapacity();
auto [header, dataPtr] = Data::allocate(capacity, grows ? QArrayData::Grow : QArrayData::KeepSize);
@@ -228,7 +228,7 @@ public:
// * when growing forward, adjust by the previous data pointer offset
// TODO: what's with CapacityReserved?
- dataPtr += (position == QArrayData::AllocateAtBeginning) ? qMax(0, (header->alloc - from.size - n) / 2)
+ dataPtr += (position == QArrayData::GrowsAtBeginning) ? qMax(0, (header->alloc - from.size - n) / 2)
: from.freeSpaceAtBegin();
header->flags = from.flags();
return QArrayDataPointer(header, dataPtr);
@@ -249,12 +249,12 @@ public:
Q_ASSERT(n > 0);
if constexpr (!QTypeInfo<T>::isRelocatable || alignof(T) > alignof(std::max_align_t)) {
- QArrayDataPointer dd(allocateGrow(from, n, QArrayData::AllocateAtEnd));
+ QArrayDataPointer dd(allocateGrow(from, n, QArrayData::GrowsAtEnd));
dd->copyAppend(from.data(), from.data() + from.size);
from.swap(dd);
} else {
if (from.needsDetach()) {
- QArrayDataPointer dd(allocateGrow(from, n, QArrayData::AllocateAtEnd));
+ QArrayDataPointer dd(allocateGrow(from, n, QArrayData::GrowsAtEnd));
dd->copyAppend(from.data(), from.data() + from.size);
from.swap(dd);
} else {
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 0d29c459df..b4070a27fc 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -670,7 +670,7 @@ inline void QList<T>::append(const_iterator i1, const_iterator i2)
return;
const auto distance = std::distance(i1, i2);
if (d->needsDetach() || distance > d.freeSpaceAtEnd()) {
- DataPointer detached(DataPointer::allocateGrow(d, distance, QArrayData::AllocateAtEnd));
+ DataPointer detached(DataPointer::allocateGrow(d, distance, QArrayData::GrowsAtEnd));
detached->copyAppend(constBegin(), constEnd());
detached->copyAppend(i1, i2);
d.swap(detached);
@@ -689,7 +689,7 @@ inline void QList<T>::append(QList<T> &&other)
return append(other);
if (d->needsDetach() || other.size() > d.freeSpaceAtEnd()) {
- DataPointer detached(DataPointer::allocateGrow(d, other.size(), QArrayData::AllocateAtEnd));
+ DataPointer detached(DataPointer::allocateGrow(d, other.size(), QArrayData::GrowsAtEnd));
if (!d->needsDetach())
detached->moveAppend(begin(), end());
@@ -709,7 +709,7 @@ template<typename... Args>
inline typename QList<T>::reference QList<T>::emplaceFront(Args &&... args)
{
if (d->needsDetach() || !d.freeSpaceAtBegin()) {
- DataPointer detached(DataPointer::allocateGrow(d, 1, QArrayData::AllocateAtBeginning));
+ DataPointer detached(DataPointer::allocateGrow(d, 1, QArrayData::GrowsAtBeginning));
detached->emplaceBack(std::forward<Args>(args)...);
if (!d.needsDetach())
@@ -742,9 +742,9 @@ QList<T>::emplace(qsizetype i, Args&&... args)
Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
if (d->needsDetach() || (d.size == d.constAllocatedCapacity())) {
- typename QArrayData::AllocationPosition pos = QArrayData::AllocateAtEnd;
+ typename QArrayData::GrowthPosition pos = QArrayData::GrowsAtEnd;
if (d.size != 0 && i <= (d.size >> 1))
- pos = QArrayData::AllocateAtBeginning;
+ pos = QArrayData::GrowsAtBeginning;
DataPointer detached(DataPointer::allocateGrow(d, 1, pos));
const_iterator where = constBegin() + i;
@@ -772,7 +772,7 @@ inline typename QList<T>::reference QList<T>::emplaceBack(Args &&... args)
// condition below should follow the condition in QArrayDataPointer::reallocateGrow()
if constexpr (!QTypeInfo<T>::isRelocatable || alignof(T) > alignof(std::max_align_t)) {
// avoid taking a temporary copy of Args
- DataPointer detached(DataPointer::allocateGrow(d, 1, QArrayData::AllocateAtEnd));
+ DataPointer detached(DataPointer::allocateGrow(d, 1, QArrayData::GrowsAtEnd));
detached->copyAppend(constBegin(), constEnd());
detached->emplace(detached.end(), std::forward<Args>(args)...);
d.swap(detached);