Cache for netclass pattern assignments.

This commit is contained in:
Jeff Young 2023-03-06 13:55:40 +00:00
parent a1fb8e1b1d
commit 9b9efb9002
5 changed files with 14 additions and 0 deletions

View File

@ -86,6 +86,8 @@ bool DIALOG_ASSIGN_NETCLASS::TransferDataFromWindow()
m_netclassCtrl->GetStringSelection() m_netclassCtrl->GetStringSelection()
} ); } );
netSettings->m_NetClassPatternAssignmentCache.clear();
return true; return true;
} }

View File

@ -411,6 +411,8 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow()
std::make_unique<EDA_COMBINED_MATCHER>( pattern, CTX_NETCLASS ), std::make_unique<EDA_COMBINED_MATCHER>( pattern, CTX_NETCLASS ),
netclass netclass
} ); } );
m_netSettings->m_NetClassPatternAssignmentCache.clear();
} }
return true; return true;

View File

@ -391,14 +391,22 @@ std::shared_ptr<NETCLASS> NET_SETTINGS::GetEffectiveNetClass( const wxString& aN
if( it != m_NetClassLabelAssignments.end() ) if( it != m_NetClassLabelAssignments.end() )
return getNetclass( it->second ); return getNetclass( it->second );
auto it2 = m_NetClassPatternAssignmentCache.find( aNetName );
if( it2 != m_NetClassPatternAssignmentCache.end() )
return getNetclass( it2->second );
for( const auto& [ matcher, netclassName ] : m_NetClassPatternAssignments ) for( const auto& [ matcher, netclassName ] : m_NetClassPatternAssignments )
{ {
int matches; int matches;
int offset; int offset;
if( matcher->Find( aNetName, matches, offset ) && offset == 0 ) if( matcher->Find( aNetName, matches, offset ) && offset == 0 )
{
m_NetClassPatternAssignmentCache[ aNetName ] = netclassName;
return getNetclass( netclassName ); return getNetclass( netclassName );
} }
}
return m_DefaultNetClass; return m_DefaultNetClass;
} }

View File

@ -43,6 +43,7 @@ public:
std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>> std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>
m_NetClassPatternAssignments; m_NetClassPatternAssignments;
mutable std::map<wxString, wxString> m_NetClassPatternAssignmentCache;
std::map<wxString, wxString> m_NetClassLabelAssignments; std::map<wxString, wxString> m_NetClassLabelAssignments;

View File

@ -203,6 +203,7 @@ void BOARD::SetProject( PROJECT* aProject, bool aReferenceOnly )
projectSettings->m_NetClasses = legacySettings->m_NetClasses; projectSettings->m_NetClasses = legacySettings->m_NetClasses;
projectSettings->m_NetClassPatternAssignments = projectSettings->m_NetClassPatternAssignments =
std::move( legacySettings->m_NetClassPatternAssignments ); std::move( legacySettings->m_NetClassPatternAssignments );
projectSettings->m_NetClassPatternAssignmentCache.clear();
} }
// Now update the DesignSettings' netclass pointer to point into the project. // Now update the DesignSettings' netclass pointer to point into the project.