Commit 492cfb73 authored by Stefan Brüns's avatar Stefan Brüns
Browse files

[FileItemRolesUpdater] Use STL-style iterator instead of iterating a copy

QSet<T>::erase(it) is the save way of erasing from a QSet while iterating
it. This saves creating a copy of the QSet, lookup of a node by value in
`QSet<T>::remove(item)`, and repeated rehashing caused by `remove`.
parent 7c0b5c08
Pipeline #51201 passed with stage
in 7 minutes and 6 seconds
......@@ -957,15 +957,17 @@ void KFileItemModelRolesUpdater::updateChangedItems()
visibleChangedIndexes.reserve(m_changedItems.size());
invisibleChangedIndexes.reserve(m_changedItems.size());
// Iterate over a const copy because items are deleted within the loop
const auto changedItems = m_changedItems;
for (const KFileItem &item : changedItems) {
auto oldsize = m_changedItems.size();
auto changedItemsIt = m_changedItems.begin();
while (changedItemsIt != m_changedItems.end()) {
const auto& item = *changedItemsIt;
const int index = m_model->index(item);
if (index < 0) {
m_changedItems.remove(item);
changedItemsIt = m_changedItems.erase(changedItemsIt);
continue;
}
++changedItemsIt;
if (index >= m_firstVisibleIndex && index <= m_lastVisibleIndex) {
visibleChangedIndexes.append(index);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment