From 978d3d01cfa063017fdce1391b60efb7a4fc8df2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Sep 2012 11:19:57 +0200 Subject: [PATCH] Use a QVector to store QPersistentModelIndexes. QPersistentModelIndex is not so big that it causes very bad QList performance, but considering how we use the container, QVector is fine. We never prepend to the container, we only ever append, clear and iterate over it. Change-Id: If1e53db9252c22340f1e0179b14a460495b5b35d Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qitemselectionmodel.cpp | 6 +++--- src/corelib/itemmodels/qitemselectionmodel_p.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 6932df8491..d55cbe9d97 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -459,9 +459,9 @@ QModelIndexList QItemSelection::indexes() const return result; } -static QList qSelectionPersistentindexes(const QItemSelection &sel) +static QVector qSelectionPersistentindexes(const QItemSelection &sel) { - QList result; + QVector result; QList::const_iterator it = sel.constBegin(); for (; it != sel.constEnd(); ++it) indexesFromRange(*it, result); @@ -846,7 +846,7 @@ void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged() Merges \a indexes into an item selection made up of ranges. Assumes that the indexes are sorted. */ -static QItemSelection mergeIndexes(const QList &indexes) +static QItemSelection mergeIndexes(const QVector &indexes) { QItemSelection colSpans; // merge columns diff --git a/src/corelib/itemmodels/qitemselectionmodel_p.h b/src/corelib/itemmodels/qitemselectionmodel_p.h index 987ea6d11a..cc278346ff 100644 --- a/src/corelib/itemmodels/qitemselectionmodel_p.h +++ b/src/corelib/itemmodels/qitemselectionmodel_p.h @@ -98,8 +98,8 @@ public: QItemSelection currentSelection; QPersistentModelIndex currentIndex; QItemSelectionModel::SelectionFlags currentCommand; - QList savedPersistentIndexes; - QList savedPersistentCurrentIndexes; + QVector savedPersistentIndexes; + QVector savedPersistentCurrentIndexes; // optimization when all indexes are selected bool tableSelected; QPersistentModelIndex tableParent;