QVLA: Skip one unneeded reallocate call for assign()

Change-Id: I09bc8835335df82aca10aa16d1902e7a1e79a10c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Mårten Nordheim 2023-02-16 11:19:35 +01:00
parent eb85a5eee7
commit cb15967014

View File

@ -781,10 +781,8 @@ Q_OUTOFLINE_TEMPLATE void QVLABase<T>::assign_impl(qsizetype prealloc, void *arr
// This function only provides the basic exception guarantee. // This function only provides the basic exception guarantee.
if constexpr (std::is_convertible_v<typename std::iterator_traits<Iterator>::iterator_category, std::forward_iterator_tag>) { if constexpr (std::is_convertible_v<typename std::iterator_traits<Iterator>::iterator_category, std::forward_iterator_tag>) {
const qsizetype n = std::distance(first, last); const qsizetype n = std::distance(first, last);
if (n > capacity()) { if (n > capacity())
reallocate_impl(prealloc, array, 0, capacity()); // clear reallocate_impl(prealloc, array, 0, n); // clear & reserve n
reallocate_impl(prealloc, array, 0, n); // reserve n
}
} }
auto dst = begin(); auto dst = begin();