diff options
author | ABBAPOH <ABBAPOH@nextmail.ru> | 2012-06-08 13:43:55 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-15 08:10:57 (GMT) |
commit | d5897ec7bb10440259a6d5424bd2ac2bdd4e1a74 (patch) | |
tree | 87ecc4096ad610c181092c3237e1990bce1bc5c3 /src/gui/itemviews | |
parent | f48918b7f32179ab034bdc5157876e230d70ba3e (diff) | |
download | Qt-d5897ec7bb10440259a6d5424bd2ac2bdd4e1a74.zip Qt-d5897ec7bb10440259a6d5424bd2ac2bdd4e1a74.tar.gz Qt-d5897ec7bb10440259a6d5424bd2ac2bdd4e1a74.tar.bz2 |
AbstractItemView editorForIndex/indexForEditor speedup
Frequent calls to editorForIndex/indexForEditor are very slow because of
an implicit conversion from QModelIndex to QPersistentModelIndex.
This fix allows to avoid unnecessary conversions when there are no open
editors (most common case)
Backport of the 1d859ef80540ec3dd64f4f7bda3a8e415965650c commit in qtbase
Change-Id: Id4f8c985b824a83019dc8a8543dee69c12004faa
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index ef69b7d..92229a2 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -4133,6 +4133,10 @@ const QEditorInfo & QAbstractItemViewPrivate::editorForIndex(const QModelIndex & { static QEditorInfo nullInfo; + // do not try to search to avoid slow implicit cast from QModelIndex to QPersistentModelIndex + if (indexEditorHash.isEmpty()) + return nullInfo; + QIndexEditorHash::const_iterator it = indexEditorHash.find(index); if (it == indexEditorHash.end()) return nullInfo; @@ -4142,7 +4146,11 @@ const QEditorInfo & QAbstractItemViewPrivate::editorForIndex(const QModelIndex & QModelIndex QAbstractItemViewPrivate::indexForEditor(QWidget *editor) const { - QEditorIndexHash::const_iterator it = editorIndexHash.find(editor); + // do not try to search to avoid slow implicit cast from QModelIndex to QPersistentModelIndex + if (indexEditorHash.isEmpty()) + return QModelIndex(); + + QEditorIndexHash::const_iterator it = editorIndexHash.find(editor); if (it == editorIndexHash.end()) return QModelIndex(); |