diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2024-04-30 14:58:20 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2024-05-01 11:13:03 +0200 |
commit | a7bb69fb87219673a530af0143660267a3ffd2d8 (patch) | |
tree | 2c7127c71ee44805747c57dc063fcbb4ebdd0659 /src/corelib | |
parent | f24a03a22a863eac18a3981973f6a19aef3116f6 (diff) |
QVLA::erase: use trivial relocation
Apply the same algorithm that QVector uses for erasing elements:
destroy the erased range, then memmove the tail over.
Change-Id: I6f2edde5b208910b665f85167cf9359379137a85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 6489c66ea3..0a579bf487 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -968,10 +968,11 @@ Q_OUTOFLINE_TEMPLATE auto QVLABase<T>::erase(const_iterator abegin, const_iterat Q_ASSERT(n > 0); // aend must be reachable from abegin - if constexpr (QTypeInfo<T>::isComplex) { + if constexpr (!QTypeInfo<T>::isRelocatable) { std::move(begin() + l, end(), QT_MAKE_CHECKED_ARRAY_ITERATOR(begin() + f, size() - f)); std::destroy(end() - n, end()); } else { + std::destroy(abegin, aend); memmove(static_cast<void *>(data() + f), static_cast<const void *>(data() + l), (size() - l) * sizeof(T)); } this->s -= n; |