]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[FileItemRolesUpdater] Reserve space in two temporary lists
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Mon, 15 Feb 2021 16:34:01 +0000 (17:34 +0100)
committerStefan Brüns <stefan.bruens@rwth-aachen.de>
Mon, 15 Feb 2021 16:34:01 +0000 (17:34 +0100)
Reserve sufficient space to avoid reallocation later. Overallocating
actually requires less memory than growing and copying it, and it
is freed immediately after anyway.

src/kitemviews/kfileitemmodelrolesupdater.cpp

index 0554bff60e01deb999a7a1b23da6dd4526fc8228..d18387f512d6e8a3b253d47f6163ebd942489eaa 100644 (file)
@@ -954,6 +954,8 @@ void KFileItemModelRolesUpdater::updateChangedItems()
 
     QList<int> visibleChangedIndexes;
     QList<int> 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;