QVLA: always use new to create new objects

Even for non-complex types, it makes no sense to use the assignment
operator instead of placement new when constructing new objects.

Pick-to: 6.0 5.15
Change-Id: I5f15fe4b3397cf52d1d35e6c4dcc513b94b3cf14
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2020-11-24 16:08:30 +01:00
parent cc1c40c2de
commit e6e67f31c1

View File

@ -220,18 +220,10 @@ public:
T copy(t);
reallocate(s, s << 1);
const qsizetype idx = s++;
if (QTypeInfo<T>::isComplex) {
new (ptr + idx) T(std::move(copy));
} else {
ptr[idx] = std::move(copy);
}
new (ptr + idx) T(std::move(copy));
} else {
const qsizetype idx = s++;
if (QTypeInfo<T>::isComplex) {
new (ptr + idx) T(t);
} else {
ptr[idx] = t;
}
new (ptr + idx) T(t);
}
}
@ -240,10 +232,7 @@ public:
if (s == a)
reallocate(s, s << 1);
const qsizetype idx = s++;
if (QTypeInfo<T>::isComplex)
new (ptr + idx) T(std::move(t));
else
ptr[idx] = std::move(t);
new (ptr + idx) T(std::move(t));
}
void append(const T *buf, qsizetype size);