From de30dc9f5df92d6d7ce3743883551f64aecc989e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 10 Mar 2017 20:53:09 +0100 Subject: [PATCH] Speed up schematic libraries loading. --- eeschema/class_library.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 22b4a6fbe4..5dd0299f20 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -287,19 +287,18 @@ PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR, bo { std::unique_ptr lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) ); - wxArrayString tmp; + std::vector aliases; + // This loads the library. + lib->GetAliases( aliases ); - // This loads the library although we could probably do lazy loading. - lib->GetAliasNames( tmp ); - - // This not them most efficient way to set the LIB_PART m_library member but it will - // only be used when loading legacy libraries in the future. Once the symbols in the + // Now, set the LIB_PART m_library member but it will only be used + // when loading legacy libraries in the future. Once the symbols in the // schematic have a full #LIB_ID, this will not get called. - for( size_t i = 0; i < tmp.GetCount(); i++ ) + for( size_t ii = 0; ii < aliases.size(); ii++ ) { - LIB_ALIAS* alias = lib->FindAlias( tmp[i] ); + LIB_ALIAS* alias = aliases[ii]; - if( alias && alias->GetPart() ) + if( alias->GetPart() ) alias->GetPart()->SetLib( lib.get() ); }