diff options
author | David Faure <david.faure@kdab.com> | 2014-10-31 16:18:47 (GMT) |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2014-12-24 21:33:13 (GMT) |
commit | 62323e8d1b16167662c85e412d35804418593cc6 (patch) | |
tree | 8e3379e568e18871e4c832f247172a74e7c011d7 /src | |
parent | 87b82fb345a3384243da50240dab93589d072d7e (diff) | |
download | Qt-62323e8d1b16167662c85e412d35804418593cc6.zip Qt-62323e8d1b16167662c85e412d35804418593cc6.tar.gz Qt-62323e8d1b16167662c85e412d35804418593cc6.tar.bz2 |
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 <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qidentityproxymodel.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/gui/itemviews/qidentityproxymodel.cpp b/src/gui/itemviews/qidentityproxymodel.cpp index 798873e..8e63901 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); } |