Avoid generating SCH_CONNECTION if not needed

If the SCH_ITEM has already been processed, the extra time needed to
iterated over the memberset and get the SCH_CONNECTION when we won't use
it is not neccesary.

Fixes https://gitlab.com/kicad/code/kicad/issues/10974

(cherry picked from commit 776a28a10e)
This commit is contained in:
Seth Hillbrand 2022-03-28 14:51:33 -07:00
parent 41f7354b7a
commit 6a33bcdc78
1 changed files with 18 additions and 4 deletions

View File

@ -761,7 +761,6 @@ void CONNECTION_GRAPH::buildItemSubGraphs()
return ( unique && conn && ( conn->SubgraphCode() == 0 ) ); return ( unique && conn && ( conn->SubgraphCode() == 0 ) );
}; };
std::copy_if( item->ConnectedItems( sheet ).begin(), std::copy_if( item->ConnectedItems( sheet ).begin(),
item->ConnectedItems( sheet ).end(), item->ConnectedItems( sheet ).end(),
std::back_inserter( memberlist ), get_items ); std::back_inserter( memberlist ), get_items );
@ -780,10 +779,16 @@ void CONNECTION_GRAPH::buildItemSubGraphs()
connected_conn->SetSubgraphCode( subgraph->m_code ); connected_conn->SetSubgraphCode( subgraph->m_code );
m_item_to_subgraph_map[connected_item] = subgraph; m_item_to_subgraph_map[connected_item] = subgraph;
subgraph->AddItem( connected_item ); subgraph->AddItem( connected_item );
SCH_ITEM_SET citemset = connected_item->ConnectedItems( sheet ); SCH_ITEM_SET& citemset = connected_item->ConnectedItems( sheet );
std::copy_if( citemset.begin(), citemset.end(), for( SCH_ITEM* citem : citemset )
std::back_inserter( memberlist ), get_items ); {
if( citem->HasFlag( CANDIDATE ) )
continue;
if( get_items( citem ) )
memberlist.push_back( citem );
}
} }
} }
@ -1358,8 +1363,13 @@ void CONNECTION_GRAPH::buildConnectionGraph()
m_bus_alias_cache[ alias->GetName() ] = alias; m_bus_alias_cache[ alias->GetName() ] = alias;
} }
PROF_TIMER sub_graph( "buildItemSubGraphs" );
buildItemSubGraphs(); buildItemSubGraphs();
if( wxLog::IsAllowedTraceMask( ConnProfileMask ) )
sub_graph.Show();
/** /**
* TODO(JE): Net codes are non-deterministic. Fortunately, they are also not really used for * TODO(JE): Net codes are non-deterministic. Fortunately, they are also not really used for
* anything. We should consider removing them entirely and just using net names everywhere. * anything. We should consider removing them entirely and just using net names everywhere.
@ -1371,8 +1381,12 @@ void CONNECTION_GRAPH::buildConnectionGraph()
generateInvisiblePinSubGraphs(); generateInvisiblePinSubGraphs();
PROF_TIMER proc_sub_graph( "ProcessSubGraphs" );
processSubGraphs(); processSubGraphs();
if( wxLog::IsAllowedTraceMask( ConnProfileMask ) )
proc_sub_graph.Show();
// Absorbed subgraphs should no longer be considered // Absorbed subgraphs should no longer be considered
alg::delete_if( m_driver_subgraphs, [&]( const CONNECTION_SUBGRAPH* candidate ) -> bool alg::delete_if( m_driver_subgraphs, [&]( const CONNECTION_SUBGRAPH* candidate ) -> bool
{ {