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()
// 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) {
changedItemsIt = m_changedItems.erase(changedItemsIt);
if (index >= m_firstVisibleIndex && index <= m_lastVisibleIndex) {
Supports Markdown
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