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/qarraydataops.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/qarraydataops.h')
| -rw-r--r-- | src/corelib/tools/qarraydataops.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index edfcd827061..03ba93198c0 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -460,8 +460,7 @@ public: const bool grows = options & (Data::GrowsForward | Data::GrowsBackwards); // ### optimize me: there may be cases when moving is not obligatory - if (this->d && !grows) { - const auto gap = this->freeSpaceAtBegin(); + if (const auto gap = this->freeSpaceAtBegin(); this->d && !grows && gap) { auto oldBegin = this->begin(); this->ptr -= gap; ::memmove(static_cast<void *>(this->begin()), static_cast<void *>(oldBegin), |
