From 9ef442b3a31868f185e575d01e3e3d35977255d6 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 9 Apr 2019 21:00:11 -0700 Subject: [PATCH] eeschema connectivity - Adjust performance in init This allow single init for map structures, improving first-run performance. --- eeschema/connection_graph.cpp | 2 +- eeschema/sch_item_struct.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index e4406fd882..a3c8f00733 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -653,7 +653,7 @@ void CONNECTION_GRAPH::buildConnectionGraph() // We don't want to spin up a new thread for fewer than 8 nets (overhead costs) size_t parallelThreadCount = std::min( std::thread::hardware_concurrency(), - ( m_subgraphs.size() + 7 ) / 8 ); + ( m_subgraphs.size() + 3 ) / 4 ); std::atomic nextSubgraph( 0 ); std::vector> returns( parallelThreadCount ); diff --git a/eeschema/sch_item_struct.cpp b/eeschema/sch_item_struct.cpp index 52c38a5fe2..51b600dfba 100644 --- a/eeschema/sch_item_struct.cpp +++ b/eeschema/sch_item_struct.cpp @@ -81,7 +81,7 @@ void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const { - if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT ) + if( ( m_Flags & STRUCT_DELETED ) || ( m_Flags & SKIP_STRUCT ) ) return false; return doIsConnected( aPosition ); @@ -90,18 +90,14 @@ bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const SCH_CONNECTION* SCH_ITEM::Connection( const SCH_SHEET_PATH& aSheet ) const { - SCH_CONNECTION* conn = nullptr; - - if( m_connection_map.count( aSheet ) ) + try { - conn = m_connection_map.at( aSheet ); + return m_connection_map.at( aSheet ); } - else + catch( ... ) { - // TODO(JE) should we just call InitializeConnection here? + return nullptr; } - - return conn; }