QTreeView: small optimization in verticalOffset()
When the scroll mode is ScrollPerItem and uniformRowHeights is not set, the offset has to be calculated by iterating over all items. Optimize the loop by calculating the last item before the loop instead of checking at every iteration. Task-number: QTBUG-61763 Change-Id: I1d4439fe0fc3f32194f5f368c0486e793048d965 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
This commit is contained in:
parent
2672a9a767
commit
daba850df8
@ -2153,12 +2153,10 @@ int QTreeView::verticalOffset() const
|
||||
// ### find a faster way to do this
|
||||
d->executePostedLayout();
|
||||
int offset = 0;
|
||||
for (int i = 0; i < d->viewItems.count(); ++i) {
|
||||
if (i == verticalScrollBar()->value())
|
||||
return offset;
|
||||
const int cnt = std::min(d->viewItems.count(), verticalScrollBar()->value());
|
||||
for (int i = 0; i < cnt; ++i)
|
||||
offset += d->itemHeight(i);
|
||||
}
|
||||
return 0;
|
||||
return offset;
|
||||
}
|
||||
// scroll per pixel
|
||||
return verticalScrollBar()->value();
|
||||
|
Loading…
Reference in New Issue
Block a user