]> cloud.milkyroute.net Git - dolphin.git/commitdiff
KFileItemModel::insertItems(): reserve sufficient space for m_items
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 6 Feb 2013 17:58:54 +0000 (18:58 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 6 Feb 2013 17:58:54 +0000 (18:58 +0100)
This prevents expensive and unnecessary repeated rehashing when many
items are inserted into the model.

src/kitemviews/kfileitemmodel.cpp

index e315eee505236e9778c75327d154afe330eaacf4..a763b3fff15d7f40ba836b664333902ffc298f73 100644 (file)
@@ -987,6 +987,7 @@ void KFileItemModel::insertItems(const KFileItemList& items)
     // The indexes of all m_items must be adjusted, not only the index
     // of the new items
     const int itemDataCount = m_itemData.count();
+    m_items.reserve(itemDataCount);
     for (int i = 0; i < itemDataCount; ++i) {
         m_items.insert(m_itemData.at(i)->item.url(), i);
     }