QVector: in append(), if we take a copy, then move, not copy from the copy

Replaces one copy ctor / assignment with a move ctor / assignment.

Change-Id: I56768db9904283a9be7c87f624a557a64557bc8f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Marc Mutz 2015-07-19 10:25:30 +02:00
parent 4d8a83f2cb
commit 8d1d12a328
1 changed files with 3 additions and 3 deletions

View File

@ -625,14 +625,14 @@ void QVector<T>::append(const T &t)
{
const bool isTooSmall = uint(d->size + 1) > d->alloc;
if (!isDetached() || isTooSmall) {
const T copy(t);
T copy(t);
QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default);
reallocData(d->size, isTooSmall ? d->size + 1 : d->alloc, opt);
if (QTypeInfo<T>::isComplex)
new (d->end()) T(copy);
new (d->end()) T(qMove(copy));
else
*d->end() = copy;
*d->end() = qMove(copy);
} else {
if (QTypeInfo<T>::isComplex)