From 54919e6854fcadc9849fa59fcd8c95574bab08d6 Mon Sep 17 00:00:00 2001 From: JamesJ <13408010-JamesJCode@users.noreply.gitlab.com> Date: Sun, 24 Mar 2024 20:29:15 +0000 Subject: [PATCH] Performance update for pcbnew net inspector Forces full rebuild of nets list for bulk updates over a certain size. This is more performant than iterating over all items in a bulk update. --- pcbnew/widgets/pcb_net_inspector_panel.cpp | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pcbnew/widgets/pcb_net_inspector_panel.cpp b/pcbnew/widgets/pcb_net_inspector_panel.cpp index 244c298ab1..5cbe9dbed9 100644 --- a/pcbnew/widgets/pcb_net_inspector_panel.cpp +++ b/pcbnew/widgets/pcb_net_inspector_panel.cpp @@ -963,9 +963,18 @@ void PCB_NET_INSPECTOR_PANEL::OnBoardItemsAdded( BOARD& aBoar if( !IsShownOnScreen() ) return; - for( BOARD_ITEM* item : aBoardItems ) + // Rebuild full netlist for large changes + if( aBoardItems.size() > 25 ) { - OnBoardItemAdded( aBoard, item ); + buildNetsList(); + m_netsList->Refresh(); + } + else + { + for( BOARD_ITEM* item : aBoardItems ) + { + OnBoardItemAdded( aBoard, item ); + } } } @@ -1037,9 +1046,17 @@ void PCB_NET_INSPECTOR_PANEL::OnBoardItemsRemoved( BOARD& aBo if( !IsShownOnScreen() ) return; - for( BOARD_ITEM* item : aBoardItems ) + if( aBoardItems.size() > 25 ) { - OnBoardItemRemoved( aBoard, item ); + buildNetsList(); + m_netsList->Refresh(); + } + else + { + for( BOARD_ITEM* item : aBoardItems ) + { + OnBoardItemRemoved( aBoard, item ); + } } }