Skip to content

Commit 62323e8

Browse files
dfaure-kdabdangelog
authored andcommitted
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 <[email protected]>
1 parent 87b82fb commit 62323e8

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

src/gui/itemviews/qidentityproxymodel.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex& p
162162
{
163163
Q_ASSERT(parent.isValid() ? parent.model() == this : true);
164164
Q_D(const QIdentityProxyModel);
165-
if (!hasIndex(row, column, parent))
166-
return QModelIndex();
167165
const QModelIndex sourceParent = mapToSource(parent);
168166
const QModelIndex sourceIndex = d->model->index(row, column, sourceParent);
169-
Q_ASSERT(sourceIndex.isValid());
170167
return mapFromSource(sourceIndex);
171168
}
172169

0 commit comments

Comments
 (0)