From eca8f1bf988abf7337927ed175a9d5beb0d4d837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Wed, 10 Jun 2015 12:01:11 +0100 Subject: gui: Add several QList::reserve() calls. Reduces reallocations. Change-Id: I0db16726f413a67b76a73fabd013f910ab5f5109 Reviewed-by: Marc Mutz --- src/gui/itemmodels/qstandarditemmodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui/itemmodels') diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 7dc42544eb..7ba91475f2 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -1803,6 +1803,7 @@ QList QStandardItem::takeRow(int row) int index = d->childIndex(row, 0); // Will return -1 if there are no columns if (index != -1) { int col_count = d->columnCount(); + items.reserve(col_count); for (int column = 0; column < col_count; ++column) { QStandardItem *ch = d->children.at(index + column); if (ch) @@ -2518,7 +2519,9 @@ QList QStandardItemModel::findItems(const QString &text, QModelIndexList indexes = match(index(0, column, QModelIndex()), Qt::DisplayRole, text, -1, flags); QList items; - for (int i = 0; i < indexes.size(); ++i) + const int numIndexes = indexes.size(); + items.reserve(numIndexes); + for (int i = 0; i < numIndexes; ++i) items.append(itemFromIndex(indexes.at(i))); return items; } -- cgit v1.2.3