From 66441d7a828ddcdae709cf4699420147f376bdcd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 3 Dec 2015 13:06:12 +0100 Subject: Make use of new QHash::erase(const_iterator) overload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drive-by changes: - use auto for iterators - add Q_UNLIKELY for conditions leading to a qWarning etc Change-Id: Iff8f36d67c96674d354a501b26640f73c15ce58d Reviewed-by: Thiago Macieira Reviewed-by: Sérgio Martins --- src/corelib/itemmodels/qabstractitemmodel.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 90297b9115..38a7bff182 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -607,7 +607,7 @@ void QAbstractItemModelPrivate::rowsInserted(const QModelIndex &parent, it != persistent_moved.constEnd(); ++it) { QPersistentModelIndexData *data = *it; QModelIndex old = data->index; - persistent.indexes.erase(persistent.indexes.find(old)); + persistent.indexes.erase(persistent.indexes.constFind(old)); data->index = q_func()->index(old.row() + count, old.column(), parent); if (data->index.isValid()) { persistent.insertMultiAtEnd(data->index, data); @@ -700,7 +700,7 @@ void QAbstractItemModelPrivate::movePersistentIndexes(const QVectorindex)); + persistent.indexes.erase(persistent.indexes.constFind(data->index)); data->index = q_func()->index(row, column, parent); if (data->index.isValid()) { persistent.insertMultiAtEnd(data->index, data); @@ -767,7 +767,7 @@ void QAbstractItemModelPrivate::rowsRemoved(const QModelIndex &parent, it != persistent_moved.constEnd(); ++it) { QPersistentModelIndexData *data = *it; QModelIndex old = data->index; - persistent.indexes.erase(persistent.indexes.find(old)); + persistent.indexes.erase(persistent.indexes.constFind(old)); data->index = q_func()->index(old.row() - count, old.column(), parent); if (data->index.isValid()) { persistent.insertMultiAtEnd(data->index, data); @@ -779,7 +779,7 @@ void QAbstractItemModelPrivate::rowsRemoved(const QModelIndex &parent, for (QVector::const_iterator it = persistent_invalidated.constBegin(); it != persistent_invalidated.constEnd(); ++it) { QPersistentModelIndexData *data = *it; - persistent.indexes.erase(persistent.indexes.find(data->index)); + persistent.indexes.erase(persistent.indexes.constFind(data->index)); data->index = QModelIndex(); data->model = 0; } @@ -812,7 +812,7 @@ void QAbstractItemModelPrivate::columnsInserted(const QModelIndex &parent, it != persistent_moved.constEnd(); ++it) { QPersistentModelIndexData *data = *it; QModelIndex old = data->index; - persistent.indexes.erase(persistent.indexes.find(old)); + persistent.indexes.erase(persistent.indexes.constFind(old)); data->index = q_func()->index(old.row(), old.column() + count, parent); if (data->index.isValid()) { persistent.insertMultiAtEnd(data->index, data); @@ -862,7 +862,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, it != persistent_moved.constEnd(); ++it) { QPersistentModelIndexData *data = *it; QModelIndex old = data->index; - persistent.indexes.erase(persistent.indexes.find(old)); + persistent.indexes.erase(persistent.indexes.constFind(old)); data->index = q_func()->index(old.row(), old.column() - count, parent); if (data->index.isValid()) { persistent.insertMultiAtEnd(data->index, data); @@ -874,7 +874,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, for (QVector::const_iterator it = persistent_invalidated.constBegin(); it != persistent_invalidated.constEnd(); ++it) { QPersistentModelIndexData *data = *it; - persistent.indexes.erase(persistent.indexes.find(data->index)); + persistent.indexes.erase(persistent.indexes.constFind(data->index)); data->index = QModelIndex(); data->model = 0; } @@ -3160,8 +3160,8 @@ void QAbstractItemModel::changePersistentIndex(const QModelIndex &from, const QM if (d->persistent.indexes.isEmpty()) return; // find the data and reinsert it sorted - const QHash::iterator it = d->persistent.indexes.find(from); - if (it != d->persistent.indexes.end()) { + const auto it = d->persistent.indexes.constFind(from); + if (it != d->persistent.indexes.cend()) { QPersistentModelIndexData *data = *it; d->persistent.indexes.erase(it); data->index = to; @@ -3194,8 +3194,8 @@ void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from, for (int i = 0; i < from.count(); ++i) { if (from.at(i) == to.at(i)) continue; - const QHash::iterator it = d->persistent.indexes.find(from.at(i)); - if (it != d->persistent.indexes.end()) { + const auto it = d->persistent.indexes.constFind(from.at(i)); + if (it != d->persistent.indexes.cend()) { QPersistentModelIndexData *data = *it; d->persistent.indexes.erase(it); data->index = to.at(i); -- cgit v1.2.3