From db526e581cf8430464a4f98a8c606f7a4ca181ff Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 7 Aug 2023 20:33:13 +0100 Subject: [PATCH] Don't call driverName() unless we have a cache miss. (That is, in fact, the whole purpose of this cache.) (cherry picked from commit e48a96ecaf89d7b3324b8cd27b87bb69a93643e4) --- eeschema/connection_graph.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 91ce224bea..60edd63824 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -356,9 +356,12 @@ wxString CONNECTION_SUBGRAPH::driverName( SCH_ITEM* aItem ) const const wxString& CONNECTION_SUBGRAPH::GetNameForDriver( SCH_ITEM* aItem ) const { - auto [it, success] = m_driver_name_cache.try_emplace( aItem, driverName( aItem ) ); + auto it = m_driver_name_cache.find( aItem ); - return it->second; + if( it != m_driver_name_cache.end() ) + return it->second; + + return m_driver_name_cache.emplace( aItem, driverName( aItem ) ).first->second; }