Move connected_items from hash table to tree

This gains about 10% speed in heavily connected sheets

Fixes https://gitlab.com/kicad/code/kicad/issues/10974
This commit is contained in:
Seth Hillbrand 2022-03-11 13:37:03 -08:00
parent 17b1b68ac7
commit 187aa1c171
3 changed files with 13 additions and 1 deletions

View File

@ -366,6 +366,9 @@ void CONNECTION_SUBGRAPH::UpdateItemConnections()
{
SCH_CONNECTION* item_conn = item->GetOrInitConnection( m_sheet, m_graph );
if( !item_conn )
continue;
if( ( m_driver_connection->IsBus() && item_conn->IsNet() ) ||
( m_driver_connection->IsNet() && item_conn->IsBus() ) )
{

View File

@ -26,6 +26,7 @@
#define SCH_ITEM_H
#include <unordered_map>
#include <map>
#include <set>
#include <eda_item.h>
@ -491,7 +492,7 @@ protected:
// to store a initial pos of the item or mouse cursor
/// Store pointers to other items that are connected to this one, per sheet.
std::unordered_map<SCH_SHEET_PATH, SCH_ITEM_SET> m_connected_items;
std::map<SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMP> m_connected_items;
/// Store connectivity information, per sheet.
std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;

View File

@ -393,6 +393,14 @@ namespace std
};
}
struct SHEET_PATH_CMP
{
bool operator()( const SCH_SHEET_PATH& lhs, const SCH_SHEET_PATH& rhs ) const
{
return lhs.GetCurrentHash() < rhs.GetCurrentHash();
}
};
typedef std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS;
typedef SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER;