From 3de0f442b5857915f26be6600bc8e54d1af08208 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 22 Oct 2014 10:04:01 +0200 Subject: QIdentityProxyModel: remove slow bounds-checking, for more performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: I45ad6249ea6c6c719a28d25a03b6e5003f4e49ee Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart Reviewed-by: Jørgen Lind --- src/corelib/itemmodels/qidentityproxymodel.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/corelib/itemmodels') diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index 27100c9ff7..e3b363f190 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -152,11 +152,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