Performance: Cache BOARD::GetMaxClearanceValue
(cherry picked from commit fe1c73ed7c
)
1b35a512 Performance
This commit is contained in:
parent
8ce12fb1af
commit
8b281b4d1c
|
@ -80,6 +80,8 @@ BOARD::BOARD() :
|
|||
m_project( nullptr ),
|
||||
m_userUnits( EDA_UNITS::MILLIMETRES ),
|
||||
m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ),
|
||||
m_deleting( false ),
|
||||
m_maxClearanceValue( 0 ),
|
||||
m_NetInfo( this )
|
||||
{
|
||||
// A too small value do not allow connecting 2 shapes (i.e. segments) not exactly connected
|
||||
|
@ -131,6 +133,8 @@ BOARD::BOARD() :
|
|||
|
||||
BOARD::~BOARD()
|
||||
{
|
||||
m_deleting = true;
|
||||
|
||||
// Untangle group parents before doing any deleting
|
||||
for( PCB_GROUP* group : m_groups )
|
||||
{
|
||||
|
@ -254,6 +258,8 @@ void BOARD::IncrementTimeStamp()
|
|||
{
|
||||
m_timeStamp++;
|
||||
|
||||
UpdateMaxClearanceCache();
|
||||
|
||||
if( !m_IntersectsAreaCache.empty()
|
||||
|| !m_EnclosedByAreaCache.empty()
|
||||
|| !m_IntersectsCourtyardCache.empty()
|
||||
|
@ -772,8 +778,12 @@ BOARD_DESIGN_SETTINGS& BOARD::GetDesignSettings() const
|
|||
}
|
||||
|
||||
|
||||
int BOARD::GetMaxClearanceValue() const
|
||||
void BOARD::UpdateMaxClearanceCache()
|
||||
{
|
||||
// in destructor, useless work
|
||||
if( m_deleting )
|
||||
return;
|
||||
|
||||
int worstClearance = m_designSettings->GetBiggestClearanceValue();
|
||||
|
||||
for( ZONE* zone : m_zones )
|
||||
|
@ -790,7 +800,7 @@ int BOARD::GetMaxClearanceValue() const
|
|||
worstClearance = std::max( worstClearance, zone->GetLocalClearance() );
|
||||
}
|
||||
|
||||
return worstClearance;
|
||||
m_maxClearanceValue = worstClearance;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1133,7 +1133,10 @@ public:
|
|||
* the clearances from board design settings as well as embedded clearances in footprints,
|
||||
* pads and zones. Includes electrical, physical, hole and edge clearances.
|
||||
*/
|
||||
int GetMaxClearanceValue() const;
|
||||
int GetMaxClearanceValue() const
|
||||
{
|
||||
return m_maxClearanceValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Map all nets in the given board to nets with the same name (if any) in the destination
|
||||
|
@ -1260,6 +1263,9 @@ private:
|
|||
( l->*aFunc )( std::forward<Args>( args )... );
|
||||
}
|
||||
|
||||
|
||||
void UpdateMaxClearanceCache();
|
||||
|
||||
friend class PCB_EDIT_FRAME;
|
||||
|
||||
|
||||
|
@ -1314,6 +1320,9 @@ private:
|
|||
*/
|
||||
bool m_legacyTeardrops = false;
|
||||
|
||||
bool m_deleting; // inside destructor
|
||||
int m_maxClearanceValue; // cached value
|
||||
|
||||
NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
|
||||
|
||||
std::vector<BOARD_LISTENER*> m_listeners;
|
||||
|
|
Loading…
Reference in New Issue