Change connectivity item group from set to vector

Reserve space for new items to speed construction of connectivity graph

Fixes https://gitlab.com/kicad/code/kicad/issues/10974
This commit is contained in:
Seth Hillbrand 2022-02-28 15:56:30 -08:00 committed by Jon Evans
parent c1dcfdffb1
commit 7aebc4b11f
4 changed files with 12 additions and 8 deletions

View File

@ -625,8 +625,8 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
else else
bus_entry->m_connected_bus_items[1] = busLine; bus_entry->m_connected_bus_items[1] = busLine;
bus_entry->ConnectedItems( aSheet ).insert( busLine ); bus_entry->AddConnectionTo( aSheet, busLine );
busLine->ConnectedItems( aSheet ).insert( bus_entry ); busLine->AddConnectionTo( aSheet, bus_entry );
} }
} }
} }
@ -670,8 +670,8 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
test_item->ConnectionPropagatesTo( connected_item ) && test_item->ConnectionPropagatesTo( connected_item ) &&
bus_connection_ok ) bus_connection_ok )
{ {
connected_item->ConnectedItems( aSheet ).insert( test_item ); connected_item->AddConnectionTo( aSheet, test_item );
test_item->ConnectedItems( aSheet ).insert( connected_item ); test_item->AddConnectionTo( aSheet, connected_item );
} }
} }

View File

@ -182,7 +182,11 @@ SCH_ITEM_SET& SCH_ITEM::ConnectedItems( const SCH_SHEET_PATH& aSheet )
void SCH_ITEM::AddConnectionTo( const SCH_SHEET_PATH& aSheet, SCH_ITEM* aItem ) void SCH_ITEM::AddConnectionTo( const SCH_SHEET_PATH& aSheet, SCH_ITEM* aItem )
{ {
m_connected_items[ aSheet ].insert( aItem ); // The vector elements are small, so reserve 1k at a time to prevent re-allocations
if( m_connected_items[ aSheet ].capacity() == 0 )
m_connected_items[ aSheet ].reserve( 1024 );
m_connected_items[ aSheet ].emplace_back( aItem );
} }

View File

@ -26,7 +26,7 @@
#define SCH_ITEM_H #define SCH_ITEM_H
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <set>
#include <eda_item.h> #include <eda_item.h>
#include <plotters/plotter.h> // for PLOT_DASH_TYPE definition #include <plotters/plotter.h> // for PLOT_DASH_TYPE definition
@ -131,7 +131,7 @@ private:
}; };
typedef std::unordered_set<SCH_ITEM*> SCH_ITEM_SET; typedef std::vector<SCH_ITEM*> SCH_ITEM_SET;
/** /**

View File

@ -492,7 +492,7 @@ bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
m_isDangling = false; m_isDangling = false;
if( aPath && item.GetType() != PIN_END ) if( aPath && item.GetType() != PIN_END )
m_connected_items[ *aPath ].insert( static_cast<SCH_ITEM*>( item.GetItem() ) ); AddConnectionTo( *aPath, static_cast<SCH_ITEM*>( item.GetItem() ) );
} }
break; break;