From cd3045596ec72c3d9dbca5301999b35f88ea8be9 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 31 Aug 2022 00:13:24 -0400 Subject: [PATCH] BColumnListView: Optimize check for whether the focus row has moved. If the new row is not in an open branch, it cannot possibly have caused the focused row to have moved, and so we need neither check nor perform an invalidation if that is the case. This code has been this way since it was originally imported into Vision's (!) CVS repository in 2001 from some Be sample code area, and has not been substantially changed since it was imported into Haiku's repository in 2004. This saves quite a number of app_server round-trips and redraws when importing lots of rows to the list, which fixes the other half of the hang when changing functions in the call stack in Debugger. --- src/kits/interface/ColumnListView.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 27b7528c72..7ac13c02db 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -4387,16 +4387,16 @@ OutlineView::AddRow(BRow* row, int32 Index, BRow* parentRow) FixScrollBar(false); BRect newRowRect; - bool newRowIsInOpenBranch = FindRect(row, &newRowRect); - - if (fFocusRow && fFocusRowRect.top > newRowRect.bottom) { - // The focus row has moved. - Invalidate(fFocusRowRect); - FindRect(fFocusRow, &fFocusRowRect); - Invalidate(fFocusRowRect); - } + const bool newRowIsInOpenBranch = FindRect(row, &newRowRect); if (newRowIsInOpenBranch) { + if (fFocusRow && fFocusRowRect.top > newRowRect.bottom) { + // The focus row has moved. + Invalidate(fFocusRowRect); + FindRect(fFocusRow, &fFocusRowRect); + Invalidate(fFocusRowRect); + } + if (fCurrentState == INACTIVE) { if (newRowRect.bottom < fVisibleRect.top) { // The new row is totally above the current viewport, move