Performance for large hierarchies: lookups
Don't bother to sort sheet lists when we're just looking up a UUID, sheet count, other symbol units, etc.
This commit is contained in:
parent
68fbe98b1d
commit
e543ff0578
|
@ -907,7 +907,7 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
KIID uuid( payload );
|
||||
SCH_SHEET_PATH path;
|
||||
|
||||
if( SCH_ITEM* item = m_schematic->GetSheets().GetItem( uuid, &path ) )
|
||||
if( SCH_ITEM* item = m_schematic->GetItem( uuid, &path ) )
|
||||
{
|
||||
if( item->Type() == SCH_SHEET_T )
|
||||
payload = static_cast<SCH_SHEET*>( item )->GetShownName( false );
|
||||
|
|
|
@ -531,7 +531,7 @@ void DIALOG_ERC::OnERCItemSelected( wxDataViewEvent& aEvent )
|
|||
{
|
||||
const KIID& itemID = RC_TREE_MODEL::ToUUID( aEvent.GetItem() );
|
||||
SCH_SHEET_PATH sheet;
|
||||
SCH_ITEM* item = m_parent->Schematic().GetSheets().GetItem( itemID, &sheet );
|
||||
SCH_ITEM* item = m_parent->Schematic().GetItem( itemID, &sheet );
|
||||
|
||||
if( m_centerMarkerOnIdle )
|
||||
{
|
||||
|
|
|
@ -672,7 +672,7 @@ void DIALOG_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* aFiel
|
|||
int unit = symbol->GetUnit();
|
||||
LIB_ID libId = symbol->GetLibId();
|
||||
|
||||
for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
|
||||
for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetUnorderedSheets() )
|
||||
{
|
||||
SCH_SCREEN* screen = sheet.LastScreen();
|
||||
std::vector<SCH_SYMBOL*> otherUnits;
|
||||
|
|
|
@ -785,7 +785,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
|||
int unit = m_symbol->GetUnit();
|
||||
LIB_ID libId = m_symbol->GetLibId();
|
||||
|
||||
for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
|
||||
for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetUnorderedSheets() )
|
||||
{
|
||||
SCH_SCREEN* screen = sheet.LastScreen();
|
||||
std::vector<SCH_SYMBOL*> otherUnits;
|
||||
|
|
|
@ -239,11 +239,10 @@ void DIALOG_TABLE_PROPERTIES::getContextualTextVars( const wxString& aCrossRef,
|
|||
{
|
||||
if( !aCrossRef.IsEmpty() )
|
||||
{
|
||||
SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets();
|
||||
SCH_REFERENCE_LIST refs;
|
||||
SCH_SYMBOL* refSymbol = nullptr;
|
||||
|
||||
sheets.GetSymbols( refs );
|
||||
m_frame->Schematic().GetUnorderedSheets().GetSymbols( refs );
|
||||
|
||||
for( int jj = 0; jj < (int) refs.GetCount(); jj++ )
|
||||
{
|
||||
|
|
|
@ -165,7 +165,6 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_ITE
|
|||
if( SCH_EDIT_FRAME* schematicEditor = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
|
||||
{
|
||||
SCH_SHEET_LIST sheetList = schematicEditor->Schematic().GetSheets();
|
||||
sheetList.SortByPageNumbers( false );
|
||||
|
||||
for( const SCH_SHEET_PATH& sheet : sheetList )
|
||||
{
|
||||
|
|
|
@ -1089,7 +1089,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
|||
// File doesn't exist yet; true if we just imported something
|
||||
updateFileHistory = true;
|
||||
}
|
||||
else if( !Schematic().GetSheets().IsModified() )
|
||||
else if( !IsContentModified() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,8 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
|
|||
|
||||
|
||||
void SCH_EDIT_FRAME::MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemId aParentId,
|
||||
const NET_NAVIGATOR_ITEM_DATA* aSelection )
|
||||
const NET_NAVIGATOR_ITEM_DATA* aSelection,
|
||||
bool aSingleSheetSchematic )
|
||||
{
|
||||
wxCHECK( !aNetName.IsEmpty(), /* void */ );
|
||||
wxCHECK( m_schematic, /* void */ );
|
||||
|
@ -229,7 +230,7 @@ void SCH_EDIT_FRAME::MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemI
|
|||
m_netNavigator->SelectItem( sheetId );
|
||||
|
||||
// If there is only one sheet in the schematic, always expand the sheet tree.
|
||||
if( Schematic().GetSheets().size() == 1 )
|
||||
if( aSingleSheetSchematic )
|
||||
expandId = sheetId;
|
||||
|
||||
for( const SCH_ITEM* item : subGraph->GetItems() )
|
||||
|
@ -266,7 +267,8 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
|
|||
if( !m_netNavigator->IsShown() )
|
||||
return;
|
||||
|
||||
size_t nodeCnt = 0;
|
||||
bool singleSheetSchematic = m_schematic->GetUnorderedSheets().size() == 1;
|
||||
size_t nodeCnt = 0;
|
||||
|
||||
m_netNavigator->Freeze();
|
||||
|
||||
|
@ -290,7 +292,7 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
|
|||
nodeCnt++;
|
||||
wxTreeItemId netId = m_netNavigator->AppendItem( rootId,
|
||||
UnescapeString( net.first.Name ) );
|
||||
MakeNetNavigatorNode( net.first.Name, netId, aSelection );
|
||||
MakeNetNavigatorNode( net.first.Name, netId, aSelection, singleSheetSchematic );
|
||||
}
|
||||
|
||||
m_netNavigator->Expand( rootId );
|
||||
|
@ -307,7 +309,7 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
|
|||
|
||||
wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 );
|
||||
|
||||
MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection );
|
||||
MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -323,7 +325,7 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
|
|||
|
||||
wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 );
|
||||
|
||||
MakeNetNavigatorNode( m_highlightedConn, rootId, itemData );
|
||||
MakeNetNavigatorNode( m_highlightedConn, rootId, itemData, singleSheetSchematic );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -332,7 +334,7 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
|
|||
|
||||
wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 );
|
||||
|
||||
MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection );
|
||||
MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
|
||||
}
|
||||
|
||||
timer.Stop();
|
||||
|
|
|
@ -822,7 +822,7 @@ void SCH_EDIT_FRAME::AddCopyForRepeatItem( const SCH_ITEM* aItem )
|
|||
|
||||
EDA_ITEM* SCH_EDIT_FRAME::GetItem( const KIID& aId ) const
|
||||
{
|
||||
return Schematic().GetSheets().GetItem( aId );
|
||||
return Schematic().GetItem( aId );
|
||||
}
|
||||
|
||||
|
||||
|
@ -942,7 +942,7 @@ bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|||
|
||||
// Shutdown blocks must be determined and vetoed as early as possible
|
||||
if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
||||
&& Schematic().GetSheets().IsModified() )
|
||||
&& IsContentModified() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -990,9 +990,7 @@ bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|||
if( !Schematic().IsValid() )
|
||||
return false;
|
||||
|
||||
SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
|
||||
|
||||
if( sheetlist.IsModified() )
|
||||
if( IsContentModified() )
|
||||
{
|
||||
wxFileName fileName = Schematic().RootScreen()->GetFileName();
|
||||
wxString msg = _( "Save changes to '%s' before closing?" );
|
||||
|
@ -1013,7 +1011,7 @@ bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|||
|
||||
void SCH_EDIT_FRAME::doCloseWindow()
|
||||
{
|
||||
SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
|
||||
SCH_SHEET_LIST sheetlist = Schematic().GetUnorderedSheets();
|
||||
|
||||
// Shutdown all running tools
|
||||
if( m_toolManager )
|
||||
|
@ -2201,7 +2199,7 @@ const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
|||
|
||||
bool SCH_EDIT_FRAME::IsContentModified() const
|
||||
{
|
||||
return Schematic().GetSheets().IsModified();
|
||||
return Schematic().GetUnorderedSheets().IsModified();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2216,9 +2214,8 @@ void SCH_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
|
|||
{
|
||||
static KIID lastBrightenedItemID( niluuid );
|
||||
|
||||
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
|
||||
SCH_SHEET_PATH dummy;
|
||||
SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
|
||||
SCH_ITEM* lastItem = Schematic().GetItem( lastBrightenedItemID, &dummy );
|
||||
|
||||
if( lastItem && lastItem != aItem )
|
||||
{
|
||||
|
|
|
@ -871,7 +871,8 @@ public:
|
|||
void RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
|
||||
|
||||
void MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemId aParentId,
|
||||
const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
|
||||
const NET_NAVIGATOR_ITEM_DATA* aSelection,
|
||||
bool aSingleSheetSchematic );
|
||||
|
||||
void SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
|
||||
|
||||
|
|
|
@ -855,11 +855,10 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks,
|
|||
}
|
||||
else
|
||||
{
|
||||
SCH_SHEET_LIST sheets = schematic->GetSheets();
|
||||
SCH_REFERENCE_LIST refs;
|
||||
SCH_SYMBOL* refSymbol = nullptr;
|
||||
|
||||
sheets.GetSymbols( refs );
|
||||
schematic->GetUnorderedSheets().GetSymbols( refs );
|
||||
|
||||
for( size_t jj = 0; jj < refs.GetCount(); jj++ )
|
||||
{
|
||||
|
|
|
@ -297,8 +297,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
|
|||
}
|
||||
else if( token->IsSameAs( wxT( "##" ) ) )
|
||||
{
|
||||
SCH_SHEET_LIST sheetList = schematic->GetSheets();
|
||||
*token = wxString::Format( wxT( "%d" ), (int) sheetList.size() );
|
||||
*token = wxString::Format( wxT( "%d" ), (int) schematic->GetUnorderedSheets().size() );
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "SHEETPATH" ) ) )
|
||||
|
|
|
@ -72,7 +72,7 @@ SCHEMATIC::SCHEMATIC( PROJECT* aPrj ) :
|
|||
int unit = symbol->GetUnit();
|
||||
LIB_ID libId = symbol->GetLibId();
|
||||
|
||||
for( SCH_SHEET_PATH& sheet : GetSheets() )
|
||||
for( SCH_SHEET_PATH& sheet : GetUnorderedSheets() )
|
||||
{
|
||||
std::vector<SCH_SYMBOL*> otherUnits;
|
||||
|
||||
|
@ -314,7 +314,7 @@ std::vector<SCH_MARKER*> SCHEMATIC::ResolveERCExclusions()
|
|||
|
||||
for( auto it = settings.m_ErcExclusions.begin(); it != settings.m_ErcExclusions.end(); )
|
||||
{
|
||||
SCH_MARKER* testMarker = SCH_MARKER::DeserializeFromString( this, *it );
|
||||
SCH_MARKER* testMarker = SCH_MARKER::DeserializeFromString( sheetList, *it );
|
||||
|
||||
if( !testMarker )
|
||||
{
|
||||
|
@ -367,7 +367,7 @@ std::vector<SCH_MARKER*> SCHEMATIC::ResolveERCExclusions()
|
|||
|
||||
for( const wxString& serialized : settings.m_ErcExclusions )
|
||||
{
|
||||
SCH_MARKER* marker = SCH_MARKER::DeserializeFromString( this, serialized );
|
||||
SCH_MARKER* marker = SCH_MARKER::DeserializeFromString( sheetList, serialized );
|
||||
|
||||
if( marker )
|
||||
{
|
||||
|
@ -384,7 +384,7 @@ std::vector<SCH_MARKER*> SCHEMATIC::ResolveERCExclusions()
|
|||
|
||||
std::shared_ptr<BUS_ALIAS> SCHEMATIC::GetBusAlias( const wxString& aLabel ) const
|
||||
{
|
||||
for( const SCH_SHEET_PATH& sheet : GetSheets() )
|
||||
for( const SCH_SHEET_PATH& sheet : GetUnorderedSheets() )
|
||||
{
|
||||
for( const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
|
||||
{
|
||||
|
@ -418,11 +418,10 @@ std::set<wxString> SCHEMATIC::GetNetClassAssignmentCandidates()
|
|||
|
||||
bool SCHEMATIC::ResolveCrossReference( wxString* token, int aDepth ) const
|
||||
{
|
||||
SCH_SHEET_LIST sheetList = GetSheets();
|
||||
wxString remainder;
|
||||
wxString ref = token->BeforeFirst( ':', &remainder );
|
||||
SCH_SHEET_PATH sheetPath;
|
||||
SCH_ITEM* refItem = sheetList.GetItem( KIID( ref ), &sheetPath );
|
||||
SCH_ITEM* refItem = GetItem( KIID( ref ), &sheetPath );
|
||||
|
||||
if( refItem && refItem->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
|
@ -455,7 +454,7 @@ std::map<int, wxString> SCHEMATIC::GetVirtualPageToSheetNamesMap() const
|
|||
{
|
||||
std::map<int, wxString> namesMap;
|
||||
|
||||
for( const SCH_SHEET_PATH& sheet : GetSheets() )
|
||||
for( const SCH_SHEET_PATH& sheet : GetUnorderedSheets() )
|
||||
{
|
||||
if( sheet.size() == 1 )
|
||||
namesMap[sheet.GetVirtualPageNumber()] = _( "<root sheet>" );
|
||||
|
@ -471,7 +470,7 @@ std::map<int, wxString> SCHEMATIC::GetVirtualPageToSheetPagesMap() const
|
|||
{
|
||||
std::map<int, wxString> pagesMap;
|
||||
|
||||
for( const SCH_SHEET_PATH& sheet : GetSheets() )
|
||||
for( const SCH_SHEET_PATH& sheet : GetUnorderedSheets() )
|
||||
pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
|
||||
|
||||
return pagesMap;
|
||||
|
@ -515,12 +514,11 @@ wxString SCHEMATIC::ConvertRefsToKIIDs( const wxString& aSource ) const
|
|||
|
||||
if( isCrossRef )
|
||||
{
|
||||
SCH_SHEET_LIST sheetList = GetSheets();
|
||||
wxString remainder;
|
||||
wxString ref = token.BeforeFirst( ':', &remainder );
|
||||
SCH_REFERENCE_LIST references;
|
||||
|
||||
sheetList.GetSymbols( references );
|
||||
GetUnorderedSheets().GetSymbols( references );
|
||||
|
||||
for( size_t jj = 0; jj < references.GetCount(); jj++ )
|
||||
{
|
||||
|
@ -571,12 +569,11 @@ wxString SCHEMATIC::ConvertKIIDsToRefs( const wxString& aSource ) const
|
|||
|
||||
if( isCrossRef )
|
||||
{
|
||||
SCH_SHEET_LIST sheetList = GetSheets();
|
||||
wxString remainder;
|
||||
wxString ref = token.BeforeFirst( ':', &remainder );
|
||||
wxString remainder;
|
||||
wxString ref = token.BeforeFirst( ':', &remainder );
|
||||
|
||||
SCH_SHEET_PATH refSheetPath;
|
||||
SCH_ITEM* refItem = sheetList.GetItem( KIID( ref ), &refSheetPath );
|
||||
SCH_ITEM* refItem = GetItem( KIID( ref ), &refSheetPath );
|
||||
|
||||
if( refItem && refItem->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
|
@ -728,10 +725,10 @@ wxString SCHEMATIC::GetOperatingPoint( const wxString& aNetName, int aPrecision,
|
|||
|
||||
void SCHEMATIC::FixupJunctions()
|
||||
{
|
||||
for( const SCH_SHEET_PATH& sheet : GetSheets() )
|
||||
{
|
||||
SCH_SCREEN* screen = sheet.LastScreen();
|
||||
SCH_SCREENS screens( Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
std::deque<EDA_ITEM*> allItems;
|
||||
|
||||
for( auto item : screen->Items() )
|
||||
|
@ -830,7 +827,7 @@ void SCHEMATIC::RecordERCExclusions()
|
|||
|
||||
void SCHEMATIC::ResolveERCExclusionsPostUpdate()
|
||||
{
|
||||
SCH_SHEET_LIST sheetList = GetSheets();
|
||||
SCH_SHEET_LIST sheetList = GetUnorderedSheets();
|
||||
|
||||
for( SCH_MARKER* marker : ResolveERCExclusions() )
|
||||
{
|
||||
|
|
|
@ -102,6 +102,18 @@ public:
|
|||
return SCH_SHEET_LIST( m_rootSheet );
|
||||
}
|
||||
|
||||
SCH_SHEET_LIST GetUnorderedSheets() const
|
||||
{
|
||||
SCH_SHEET_LIST sheets;
|
||||
sheets.BuildSheetList( m_rootSheet, false );
|
||||
return sheets;
|
||||
}
|
||||
|
||||
SCH_ITEM* GetItem( const KIID& aID, SCH_SHEET_PATH* aPathOut = nullptr ) const
|
||||
{
|
||||
return GetUnorderedSheets().GetItem( aID, aPathOut );
|
||||
}
|
||||
|
||||
SCH_SHEET& Root() const
|
||||
{
|
||||
return *m_rootSheet;
|
||||
|
|
|
@ -201,7 +201,7 @@ bool SCH_NAVIGATE_TOOL::CanGoPrevious()
|
|||
bool SCH_NAVIGATE_TOOL::CanGoNext()
|
||||
{
|
||||
return m_frame->GetCurrentSheet().GetVirtualPageNumber()
|
||||
< (int) m_frame->Schematic().GetSheets().size();
|
||||
< (int) m_frame->Schematic().GetUnorderedSheets().size();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue