From: Stefan BrĂ¼ns Date: Mon, 15 Feb 2021 16:34:01 +0000 (+0100) Subject: [FileItemRolesUpdater] Reserve space in two temporary lists X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/7c0b5c08cc97eded7755ca5cef9c7e5ba5c15537 [FileItemRolesUpdater] Reserve space in two temporary lists Reserve sufficient space to avoid reallocation later. Overallocating actually requires less memory than growing and copying it, and it is freed immediately after anyway. --- diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 0554bff60..d18387f51 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -954,6 +954,8 @@ void KFileItemModelRolesUpdater::updateChangedItems() QList visibleChangedIndexes; QList invisibleChangedIndexes; + 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;