From f5be388acdb380ed454855057b0cac3da69699e5 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. --- pcbnew/footprint.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 85c646316e..5f9d9d54fc 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1246,7 +1246,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 ) { @@ -1270,6 +1269,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 )