summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvarlengtharray.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-02-24 22:15:56 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2017-02-24 23:32:33 +0000
commit63856135dacba615ebfabdf03be2926dc763358f (patch)
treea0a29ebb0572b190f837c96c5eb8f4e310601b0d /src/corelib/tools/qvarlengtharray.h
parent14db1d5560254766746446069b6f2456e4444602 (diff)
parentde49839df8abfba1f3ed3c36ef3177e4a9d6ef00 (diff)
Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r--src/corelib/tools/qvarlengtharray.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 25f5176c22..ae2c75e7df 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -146,15 +146,25 @@ public:
T value(int i, const T &defaultValue) const;
inline void append(const T &t) {
- if (s == a) // i.e. s != 0
+ if (s == a) { // i.e. s != 0
+ T copy(t);
realloc(s, s<<1);
- const int idx = s++;
- if (QTypeInfo<T>::isComplex) {
- new (ptr + idx) T(t);
+ const int idx = s++;
+ if (QTypeInfo<T>::isComplex) {
+ new (ptr + idx) T(std::move(copy));
+ } else {
+ ptr[idx] = std::move(copy);
+ }
} else {
- ptr[idx] = t;
+ const int idx = s++;
+ if (QTypeInfo<T>::isComplex) {
+ new (ptr + idx) T(t);
+ } else {
+ ptr[idx] = t;
+ }
}
}
+
void append(const T *buf, int size);
inline QVarLengthArray<T, Prealloc> &operator<<(const T &t)
{ append(t); return *this; }