Optimization in class_library.cpp: speed up power component list creation.

This commit is contained in:
jean-pierre charras 2017-03-13 12:49:24 +01:00
parent 28a6ca1e23
commit 8f3fc7b858
1 changed files with 7 additions and 15 deletions

View File

@ -166,24 +166,20 @@ void PART_LIB::GetAliases( std::vector<LIB_ALIAS*>& aAliases )
void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames ) void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames )
{ {
wxArrayString aliases; std::vector<LIB_ALIAS*> aliases;
m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath() ); m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath() );
for( size_t i = 0; i < aliases.GetCount(); i++ ) for( size_t i = 0; i < aliases.size(); i++ )
{ {
LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aliases[i], m_properties.get() ); LIB_ALIAS* alias = aliases[i];
wxCHECK2_MSG( alias != NULL, continue,
wxString::Format( "alias '%s' not found in symbol library '%s'",
aliases[i], fileName.GetFullPath() ) );
LIB_PART* root = alias->GetPart(); LIB_PART* root = alias->GetPart();
if( !root || !root->IsPower() ) if( !root || !root->IsPower() )
continue; continue;
aNames.Add( aliases[i] ); aNames.Add( alias->GetName() );
} }
aNames.Sort(); aNames.Sort();
@ -210,17 +206,13 @@ LIB_PART* PART_LIB::FindPart( const wxString& aName )
bool PART_LIB::HasPowerParts() bool PART_LIB::HasPowerParts()
{ {
// return true if at least one power part is found in lib // return true if at least one power part is found in lib
wxArrayString aliases; std::vector<LIB_ALIAS*> aliases;
m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath(), m_properties.get() ); m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath(), m_properties.get() );
for( size_t i = 0; i < aliases.GetCount(); i++ ) for( size_t i = 0; i < aliases.size(); i++ )
{ {
LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aliases[i], m_properties.get() ); LIB_ALIAS* alias = aliases[i];
wxCHECK2_MSG( alias != NULL, continue,
wxString::Format( "alias '%s' not found in symbol library '%s'",
aliases[i], fileName.GetFullPath() ) );
LIB_PART* root = alias->GetPart(); LIB_PART* root = alias->GetPart();