Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.9, 5.15.5, 6.x
-
None
Description
The current implementation of QTreeViewPrivate::viewIndex() yields bad performance if a high number of rows is not collapsed ( = QTreeViewPrivate::viewItems is huge, as in "several thousand rows"), as this results in a linear scan of all rows.
With QTreeViewPrivate::lastViewedItem being also updated by that function (some weird attempt at using locality?), any non-trivial access pattern never hits the "fast paths" encoded in the heuristics of that method.
With QTreeViewPrivate::viewIndex() being treated as "for free" in the remainder of this class, this makes up for up to 90% of the CPU time in all of QTreeView for pure model-driven data-updates.
QTreeViewPrivate::layout() should be extended to build the index QHash<QIndex, int> from "primary column index" (const QModelIndex index = _index.sibling(_index.row(), 0); in QTreeViewPrivate::viewIndex(), current in QTreeViewPrivate::layout()) to offset in viewItem alongside with viewItem itself, so that the lookup can be performed in constant time. The index must be cleared when clearing QTreeViewPrivate::viewItems.