From 6a33bcdc7813a8b41ea524d277bfde4924258cec Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 28 Mar 2022 14:51:33 -0700 Subject: [PATCH] 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 776a28a10edd1e348b6a48dec0beec631ad1a97a) --- eeschema/connection_graph.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 62b58d8add..f1241e1ecd 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -761,7 +761,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 ); @@ -780,10 +779,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 ); + } } } @@ -1358,8 +1363,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. @@ -1371,8 +1381,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 {