Load each symbol library atomically for better performance.

This commit is contained in:
Jeff Young 2018-01-24 23:29:45 +00:00 committed by Wayne Stambaugh
parent 888a9e7371
commit eb7ecf1dfd
3 changed files with 39 additions and 5 deletions

View File

@ -47,11 +47,11 @@ void CMP_TREE_MODEL_ADAPTER::AddLibrary( wxString const& aLibNickname )
{
bool onlyPowerSymbols = ( GetFilter() == CMP_FILTER_POWER );
wxArrayString aliases;
std::vector<LIB_ALIAS*> alias_list;
try
{
m_libs->EnumerateSymbolLib( aLibNickname, aliases, onlyPowerSymbols );
m_libs->LoadSymbolLib( alias_list, aLibNickname, onlyPowerSymbols );
}
catch( const IO_ERROR& ioe )
{
@ -60,9 +60,9 @@ void CMP_TREE_MODEL_ADAPTER::AddLibrary( wxString const& aLibNickname )
return;
}
if( aliases.size() > 0 )
if( alias_list.size() > 0 )
{
AddAliasList( aLibNickname, aliases );
AddAliasList( aLibNickname, alias_list );
m_tree.AssignIntrinsicRanks();
}
}

View File

@ -310,6 +310,37 @@ SYMBOL_LIB_TABLE_ROW* SYMBOL_LIB_TABLE::FindRow( const wxString& aNickname )
}
void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector<LIB_ALIAS*>& aAliasList,
const wxString& aNickname, bool aPowerSymbolsOnly )
{
SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname );
wxCHECK( row && row->plugin, /* void */ );
wxString options = row->GetOptions();
if( aPowerSymbolsOnly )
row->SetOptions( row->GetOptions() + " " + PropPowerSymsOnly );
row->plugin->EnumerateSymbolLib( aAliasList, row->GetFullURI( true ), row->GetProperties() );
if( aPowerSymbolsOnly )
row->SetOptions( options );
// The library cannot know its own name, because it might have been renamed or moved.
// Therefore footprints cannot know their own library nickname when residing in
// a symbol library.
// Only at this API layer can we tell the symbol about its actual library nickname.
for( LIB_ALIAS* alias : aAliasList )
{
// remove "const"-ness, I really do want to set nickname without
// having to copy the LIB_ID and its two strings, twice each.
LIB_ID& id = (LIB_ID&) alias->GetPart()->GetLibId();
id.SetLibNickname( row->GetNickName() );
}
}
LIB_ALIAS* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxString& aAliasName )
{
const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname );

View File

@ -160,6 +160,9 @@ public:
void EnumerateSymbolLib( const wxString& aNickname, wxArrayString& aAliasNames,
bool aPowerSymbolsOnly = false );
void LoadSymbolLib( std::vector<LIB_ALIAS*>& aAliasList, const wxString& aNickname,
bool aPowerSymbolsOnly = false );
/**
* Load a #LIB_ALIAS having @a aAliasName from the library given by @a aNickname.
*