Don't call driverName() unless we have a cache miss.

(That is, in fact, the whole purpose of this cache.)

(cherry picked from commit e48a96ecaf)
This commit is contained in:
Jeff Young 2023-08-07 20:33:13 +01:00
parent 246be732a1
commit db526e581c
1 changed files with 5 additions and 2 deletions

View File

@ -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;
}