path: root/src/corelib/itemmodels
diff options
authorDavid Faure <>2014-10-22 10:04:01 +0200
committerDavid Faure <>2014-10-31 10:38:23 +0100
commit3de0f442b5857915f26be6600bc8e54d1af08208 (patch)
tree2a1c2c7e4c2bc219fa5303b49a92eaa4368bd102 /src/corelib/itemmodels
parent6700fb0bf0bc1be7346c8184b7c112c574ba6515 (diff)
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: I45ad6249ea6c6c719a28d25a03b6e5003f4e49ee Reviewed-by: Friedemann Kleint <> Reviewed-by: Olivier Goffart <> Reviewed-by: Jørgen Lind <>
Diffstat (limited to 'src/corelib/itemmodels')
1 files changed, 0 insertions, 3 deletions
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);