Cache netclass clearances

Importing Altium boards can generate hundreds of netclasses.  Our O(N)
search was choking on the overload
This commit is contained in:
Seth Hillbrand
2026-01-09 16:15:20 -08:00
parent 03215844fd
commit e741ee2e6c
7 changed files with 170 additions and 6 deletions
+26 -4
View File
@@ -1351,12 +1351,34 @@ static void hasExactNetclassFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return 0.0;
BOARD_CONNECTED_ITEM* bcItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
NETCLASS* netclass = bcItem->GetEffectiveNetClass();
BOARD* board = bcItem->GetBoard();
wxString netclassName;
if( netclass && netclass->GetName() == arg->AsString() )
return 1.0;
if( board && ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
{
std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
return 0.0;
auto it = board->m_ItemNetclassCache.find( item );
if( it != board->m_ItemNetclassCache.end() )
netclassName = it->second;
}
if( netclassName.empty() )
{
NETCLASS* netclass = bcItem->GetEffectiveNetClass();
if( netclass )
netclassName = netclass->GetName();
if( board && !netclassName.empty() && ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
{
std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
board->m_ItemNetclassCache[item] = netclassName;
}
}
return ( netclassName == arg->AsString() ) ? 1.0 : 0.0;
} );
}