diff options
author | ABBAPOH <ABBAPOH@nextmail.ru> | 2012-06-09 16:22:50 +0400 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-13 23:22:28 +0200 |
commit | 1d859ef80540ec3dd64f4f7bda3a8e415965650c (patch) | |
tree | 456897857b45c65624c578b9d07001d09c48c2d5 | |
parent | e2f57d59d814128c5b07f26b368ea07019e154f7 (diff) |
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)
Change-Id: Ic072880c9f33a43a20b2a61a42c3ba215c5c33cb
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index bd70e83aa3..fbe1bf944e 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -4196,6 +4196,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; @@ -4205,6 +4209,10 @@ const QEditorInfo & QAbstractItemViewPrivate::editorForIndex(const QModelIndex & QModelIndex QAbstractItemViewPrivate::indexForEditor(QWidget *editor) const { + // 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(); |