From b625d29151a60ed09e010fbb9e56eaf8db4e5eaa Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 22 May 2018 15:37:24 -0700 Subject: [PATCH] Only search pads when the position hits module On large boards with high pad-count modules, searching each pad for hits becomes expensive. We eliminate many of the pad searches by first checking the module's bounding box before iterating over pads to look for hits. --- pcbnew/class_board.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index cb60db9c12..1371c56ff3 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -1556,7 +1556,10 @@ D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet ) for( MODULE* module = m_Modules; module; module = module->Next() ) { - D_PAD* pad = module->GetPad( aPosition, aLayerSet ); + D_PAD* pad = NULL; + + if( module->HitTest( aPosition ) ) + pad = module->GetPad( aPosition, aLayerSet ); if( pad ) return pad; @@ -1572,16 +1575,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint ) LSET lset( aTrace->GetLayer() ); - for( MODULE* module = m_Modules; module; module = module->Next() ) - { - D_PAD* pad = module->GetPad( aPosition, lset ); - - if( pad ) - return pad; - } - - return NULL; - + return GetPad( aPosition, lset ); }