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
This commit is contained in:
Seth Hillbrand 2022-03-28 14:51:33 -07:00
parent 3a98eacdb9
commit 776a28a10e
1 changed files with 18 additions and 4 deletions

View File

@ -738,7 +738,6 @@ void CONNECTION_GRAPH::buildItemSubGraphs()
return ( unique && conn && ( conn->SubgraphCode() == 0 ) );
};
std::copy_if( item->ConnectedItems( sheet ).begin(),
item->ConnectedItems( sheet ).end(),
std::back_inserter( memberlist ), get_items );
@ -757,10 +756,16 @@ void CONNECTION_GRAPH::buildItemSubGraphs()
connected_conn->SetSubgraphCode( subgraph->m_code );
m_item_to_subgraph_map[connected_item] = subgraph;
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(),
std::back_inserter( memberlist ), get_items );
for( SCH_ITEM* citem : citemset )
{
if( citem->HasFlag( CANDIDATE ) )
continue;
if( get_items( citem ) )
memberlist.push_back( citem );
}
}
}
@ -1335,8 +1340,13 @@ void CONNECTION_GRAPH::buildConnectionGraph()
m_bus_alias_cache[ alias->GetName() ] = alias;
}
PROF_TIMER sub_graph( "buildItemSubGraphs" );
buildItemSubGraphs();
if( wxLog::IsAllowedTraceMask( ConnProfileMask ) )
sub_graph.Show();
/**
* 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.
@ -1348,8 +1358,12 @@ void CONNECTION_GRAPH::buildConnectionGraph()
generateInvisiblePinSubGraphs();
PROF_TIMER proc_sub_graph( "ProcessSubGraphs" );
processSubGraphs();
if( wxLog::IsAllowedTraceMask( ConnProfileMask ) )
proc_sub_graph.Show();
// Absorbed subgraphs should no longer be considered
alg::delete_if( m_driver_subgraphs, [&]( const CONNECTION_SUBGRAPH* candidate ) -> bool
{