diff --git a/electrum/gui/qt/custom_model.py b/electrum/gui/qt/custom_model.py index 099e041b3..e9f9b05dc 100644 --- a/electrum/gui/qt/custom_model.py +++ b/electrum/gui/qt/custom_model.py @@ -62,12 +62,18 @@ class CustomModel(QtCore.QAbstractItemModel): parent.addChild(self, node) def index(self, row, column, _parent=None): + # Performance-critical function + if not _parent or not _parent.isValid(): parent = self._root else: parent = _parent.internalPointer() - if not QtCore.QAbstractItemModel.hasIndex(self, row, column, _parent): + # Open-coded + # if not QtCore.QAbstractItemModel.hasIndex(self, row, column, _parent): + # the implementation is equivalent but it's in C++, + # so VM entries take up inordinate amounts of time (up to 25% of refresh()): + if row < 0 or column < 0 or row >= self.rowCount(_parent) or column >= self._columncount: return QtCore.QModelIndex() child = parent.child(row)