QtCore: replace uses of inefficient QList<QPair>s with QVectors [itemmodels]
These QPairs are larger than a void*, so holding them in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by holding them in QVector instead. Change-Id: Ie8d8eff3448ada7aef5dfba7fc701a59821f5b54 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
982656351b
commit
1a84e55b8f
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QList<QPair<QModelIndex, QPersistentModelIndex> > QModelIndexPairList;
|
||||
typedef QVector<QPair<QModelIndex, QPersistentModelIndex> > QModelIndexPairList;
|
||||
|
||||
static inline QSet<int> qVectorToSet(const QVector<int> &vector)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ void QStringListModel::sort(int, Qt::SortOrder order)
|
|||
{
|
||||
emit layoutAboutToBeChanged(QList<QPersistentModelIndex>(), VerticalSortHint);
|
||||
|
||||
QList<QPair<QString, int> > list;
|
||||
QVector<QPair<QString, int> > list;
|
||||
const int lstCount = lst.count();
|
||||
list.reserve(lstCount);
|
||||
for (int i = 0; i < lstCount; ++i)
|
||||
|
|
|
|||
Loading…
Reference in New Issue