QVLA: Skip one unneeded reallocate call for assign()
Change-Id: I09bc8835335df82aca10aa16d1902e7a1e79a10c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
eb85a5eee7
commit
cb15967014
@ -781,10 +781,8 @@ Q_OUTOFLINE_TEMPLATE void QVLABase<T>::assign_impl(qsizetype prealloc, void *arr
|
||||
// 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>) {
|
||||
const qsizetype n = std::distance(first, last);
|
||||
if (n > capacity()) {
|
||||
reallocate_impl(prealloc, array, 0, capacity()); // clear
|
||||
reallocate_impl(prealloc, array, 0, n); // reserve n
|
||||
}
|
||||
if (n > capacity())
|
||||
reallocate_impl(prealloc, array, 0, n); // clear & reserve n
|
||||
}
|
||||
|
||||
auto dst = begin();
|
||||
|
Loading…
Reference in New Issue
Block a user