path: root/src/corelib/itemmodels
diff options
authorSérgio Martins <>2015-06-01 14:05:41 +0100
committerSérgio Martins <>2015-06-29 19:31:59 +0000
commit20147fae60fd062788c51b058ebb70b33d7fd664 (patch)
treee677f42184ea22f1af510814d11f7afdd6fd027f /src/corelib/itemmodels
parent29e88fd8f066c14a405a52bbfe3715dc3e5e891f (diff)
Use QVector::reserve() all over the place.
Reduces internal memory fragmentation. The search criteria was: QVector::append(), QVector::push_back(), QVector::operator<<() and QVector::operator+=() calls inside for, do and while loops. Statements inside ifs and out of loops weren't considered. Change-Id: Ie5aaf3cdfac938994e6e5dfa5f51de501ed79a0c Reviewed-by: Marc Mutz <>
Diffstat (limited to 'src/corelib/itemmodels')
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 5ae4fc0417..9692ffb675 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -2128,6 +2128,7 @@ bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &pa
// remove corresponding source intervals
// ### if this proves to be slow, we can switch to single-row removal
QVector<int> rows;
+ rows.reserve(count);
for (int i = row; i < row + count; ++i)
std::sort(rows.begin(), rows.end());
@@ -2167,6 +2168,7 @@ bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelInd
// remove corresponding source intervals
QVector<int> columns;
+ columns.reserve(count);
for (int i = column; i < column + count; ++i)