diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2020-11-02 10:18:59 +0100 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2020-11-04 10:22:16 +0000 |
| commit | 1282c05cdcc935a5eb1be150b8fd88f7771e81de (patch) | |
| tree | 584ba75a2dcd63b77d3183e7229e634325e57d2e /src/corelib/tools/qarraydatapointer.h | |
| parent | edd1e931d1f0a1c5f9b2c1869d34db577307605d (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/corelib/tools/qarraydatapointer.h')
| -rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 20015cbaddc..f6e556597f9 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 { |
