summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-28 09:16:06 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-04-28 09:16:06 +0000
commita6f7dc521b0491a4e8a163941fedecbfdce26b43 (patch)
tree1b1f7a085ed576892c9c6d7a1e1f0da2d427630d /src/corelib/tools/qvector.h
parent73a48c16189fcc1c1dd783e05c51d47711d554e2 (diff)
parent1c8451bdbbd6ca909dfc5b96a24be909810522fc (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 12baecd37c..2eb2dc4550 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -608,16 +608,23 @@ Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const
template <typename T>
void QVector<T>::append(const T &t)
{
- const T copy(t);
const bool isTooSmall = uint(d->size + 1) > d->alloc;
if (!isDetached() || isTooSmall) {
+ const 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);
+ else
+ *d->end() = copy;
+
+ } else {
+ if (QTypeInfo<T>::isComplex)
+ new (d->end()) T(t);
+ else
+ *d->end() = t;
}
- if (QTypeInfo<T>::isComplex)
- new (d->end()) T(copy);
- else
- *d->end() = copy;
++d->size;
}