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>
This commit is contained in:
Giuseppe D'Angelo 2024-04-30 14:58:20 +02:00
parent f24a03a22a
commit a7bb69fb87

View File

@ -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;