From 62323e8d1b16167662c85e412d35804418593cc6 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 31 Oct 2014 17:18:47 +0100 Subject: QIdentityProxyModel: remove slow bounds-checking, for more performance If we're called out of bounds, sourceModel()->index() will take care of returning an invalid model index anyway. So calling rowCount+columnCount every time index() is called can be avoided. These calls can be particularly slow when sitting on top of a stack of proxymodels. And index() itself is called very often, i.e. when a proxymodel on top of us is used by a delegate which calls data() for many different roles. Change-Id: I00dd5cf432c0591f41e6fa6fc86c845f29845cd1 (cherry picked from qtbase/3de0f442b5857915f26be6600bc8e54d1af08208) Reviewed-by: Giuseppe D'Angelo --- src/gui/itemviews/qidentityproxymodel.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/itemviews/qidentityproxymodel.cpp b/src/gui/itemviews/qidentityproxymodel.cpp index 798873eae2..8e6390159a 100644 --- a/src/gui/itemviews/qidentityproxymodel.cpp +++ b/src/gui/itemviews/qidentityproxymodel.cpp @@ -162,11 +162,8 @@ QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex& p { Q_ASSERT(parent.isValid() ? parent.model() == this : true); Q_D(const QIdentityProxyModel); - if (!hasIndex(row, column, parent)) - return QModelIndex(); const QModelIndex sourceParent = mapToSource(parent); const QModelIndex sourceIndex = d->model->index(row, column, sourceParent); - Q_ASSERT(sourceIndex.isValid()); return mapFromSource(sourceIndex); } -- cgit v1.2.3