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>
{
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;
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();