From b3a5ad40a752e2e6036aaed2b30a80e73a6c779f Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Wed, 4 Nov 2020 12:26:08 +0100 Subject: [PATCH] Move existing items in generic erase instead of copying them Use std::move() in QGenericArrayOps::erase() when assigning over the to-be-deleted range Task-number: QTBUG-86583 Change-Id: Ib28c5c1f1593beba5fce6841dd6fcecfdfb166ad Reviewed-by: Thiago Macieira --- src/corelib/tools/qarraydataops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 0e067bbbe5..7c12a84c10 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -802,7 +802,7 @@ public: // move (by assignment) the elements from e to end // onto b to the new end while (e != end) { - *b = *e; + *b = std::move(*e); ++b; ++e; } @@ -830,7 +830,7 @@ public: while (b != begin) { --b; --e; - *e = *b; + *e = std::move(*b); } // destroy the final elements at the begin