summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-07-19 10:25:30 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-07-19 16:00:12 +0000
commit8d1d12a32896cca3f9aaae31ae2a3ee28dc8f276 (patch)
tree3e0c9ce701c70967ea10c4049241e089df5e6a5b
parent4d8a83f2cb77e4b241a8bcd0375c7e9a9bcb38f8 (diff)
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>
-rw-r--r--src/corelib/tools/qvector.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 624d828a3b..1a7692c0f4 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -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)