Protect against subgraph loops

Optimize the subgraph processing to avoid repeated loops when multiple
items belong to the same subgraph.
This commit is contained in:
Seth Hillbrand 2023-10-05 08:39:56 -07:00
parent 239f8e0905
commit 75de21314c
1 changed files with 5 additions and 1 deletions

View File

@ -239,7 +239,11 @@ void CONNECTION_SUBGRAPH::getAllConnectedItems( std::set<std::pair<SCH_SHEET_PAT
sg = sg->m_absorbed_by;
}
aSubgraphs.insert( sg );
// If we are unable to insert the subgraph into the set, then we have already
// visited it and don't need to add it again.
if( aSubgraphs.insert( sg ).second == false )
return;
aSubgraphs.insert( sg->m_absorbed_subgraphs.begin(), sg->m_absorbed_subgraphs.end() );
for( SCH_ITEM* item : sg->m_items )