This prevents expensive and unnecessary repeated rehashing when many
items are inserted into the model.
// The indexes of all m_items must be adjusted, not only the index
// of the new items
const int itemDataCount = m_itemData.count();
// 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);
}
for (int i = 0; i < itemDataCount; ++i) {
m_items.insert(m_itemData.at(i)->item.url(), i);
}