summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2024-04-30 14:58:20 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2024-05-01 11:13:03 +0200
commita7bb69fb87219673a530af0143660267a3ffd2d8 (patch)
tree2c7127c71ee44805747c57dc063fcbb4ebdd0659 /src/corelib
parentf24a03a22a863eac18a3981973f6a19aef3116f6 (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.h3
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;