From a5cbcd4abeafca3a0fc954aed9966780cba43f2a Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Thu, 20 Jun 2024 06:01:25 +0300 Subject: [PATCH] Don't call GetSide in FOOTPRINT::GetBoundingBox when not needed. CPU usage: -13% when moving a board. (cherry picked from commit f5be388acdb380ed454855057b0cac3da69699e5) --- pcbnew/footprint.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index db65cb0213..d9e4ef648e 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -986,7 +986,6 @@ const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisible std::vector texts; const BOARD* board = GetBoard(); bool isFPEdit = board && board->IsFootprintHolder(); - PCB_LAYER_ID footprintSide = GetSide(); if( board ) { @@ -1010,6 +1009,9 @@ const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisible BOX2I bbox( m_pos ); bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox + // Calculate the footprint side + PCB_LAYER_ID footprintSide = GetSide(); + for( BOARD_ITEM* item : m_drawings ) { if( m_privateLayers.test( item->GetLayer() ) && !isFPEdit )