[FileItemRolesUpdater] Fix reservation size

The code below always adds the visible range, up to 5 pages before and
after the visible range (each capped to ResolveAllItemsLimit/2) and
the very first and last page (each up to m_maximumVisibleItems).

Use this number to avoid growing the list later.
This commit is contained in:
Stefan Brüns 2021-02-15 11:25:28 +01:00
parent b4676b71c6
commit 68704c2a28

View file

@ -1160,7 +1160,9 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
const int count = m_model->count();
QList<int> result;
result.reserve(ResolveAllItemsLimit);
result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) +
ResolveAllItemsLimit +
(2 * m_maximumVisibleItems)));
// Add visible items.
for (int i = m_firstVisibleIndex; i <= m_lastVisibleIndex; ++i) {