From 20147fae60fd062788c51b058ebb70b33d7fd664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Mon, 1 Jun 2015 14:05:41 +0100 Subject: 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 --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/itemmodels') 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 rows; + rows.reserve(count); for (int i = row; i < row + count; ++i) rows.append(m->source_rows.at(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 columns; + columns.reserve(count); for (int i = column; i < column + count; ++i) columns.append(m->source_columns.at(i)); -- cgit v1.2.3