diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-24 16:08:30 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-26 14:43:20 +0100 |
commit | e6e67f31c10da900ec6ecb06c2e827b17283be6a (patch) | |
tree | 740c3d72c0af44fbd85b375c65cfcbc8aa381a09 | |
parent | cc1c40c2de0b20e549959853f5eac4d17a326fbb (diff) |
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>
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 975d088a48..6a99602153 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -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); |