diff options
| author | Andrei Golubev <andrei.golubev@qt.io> | 2020-08-26 09:11:18 +0200 |
|---|---|---|
| committer | Andrei Golubev <andrei.golubev@qt.io> | 2020-08-27 18:58:20 +0200 |
| commit | f48dba06650801c5678ae89adfc14b1cc3209da9 (patch) | |
| tree | 699ec444d6508e4f9107dd3df47ed66e7e18fae2 /src/corelib/tools/qarraydatapointer.h | |
| parent | 15553c39f4254ae657f025f9c9177acc5cea5134 (diff) | |
Update allocation interface of QArrayDataPointer
Added overload to allocGrow that figures the capacity to allocate from
the newSize argument passed. This is useful in QList (and likely in other
places)
Fixed QArrayPodOps::reallocate as a drive by: don't call memmove when
it is not needed
Task-number: QTBUG-84320
Change-Id: I67efe55a60efaf3ab6057b0249d6a446e04a09e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydatapointer.h')
| -rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index aebc83ba3f4..ad5acdb7fdf 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -209,6 +209,12 @@ public: return d->constAllocatedCapacity() - freeSpaceAtBegin() - this->size; } + static QArrayDataPointer allocateGrow(const QArrayDataPointer &from, + qsizetype newSize, QArrayData::ArrayOptions options) + { + return allocateGrow(from, from.detachCapacity(newSize), newSize, options); + } + static QArrayDataPointer allocateGrow(const QArrayDataPointer &from, qsizetype capacity, qsizetype newSize, QArrayData::ArrayOptions options) { |
