From f48dba06650801c5678ae89adfc14b1cc3209da9 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Wed, 26 Aug 2020 09:11:18 +0200 Subject: 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 --- src/corelib/tools/qarraydataops.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib/tools/qarraydataops.h') 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(this->begin()), static_cast(oldBegin), -- cgit v1.2.3