diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 96735ae4f1..f99ff7265b 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -244,6 +245,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in if( !AskToSaveChanges() ) return false; + PROF_COUNTER openFiles( "OpenProjectFile" ); + wxFileName pro = fullFileName; pro.SetExt( ProjectFileExtension ); @@ -517,6 +520,10 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in m_infoBar->ShowMessage( "Schematic file is read only.", wxICON_WARNING ); } +#ifdef PROFILE + openFiles.Show(); +#endif + return true; } diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 472c6cb66d..c247e92ffd 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -773,6 +773,20 @@ void SCH_SHEET_LIST::UpdateSymbolInstances( GetComponents( symbolInstances, true, true ); + std::map pathNameCache; + + // Calculating the name of a path is somewhat expensive; on large designs with many components + // this can blow up to a serious amount of time when loading the schematic + auto getName = + [&pathNameCache]( const KIID_PATH& aPath ) -> const wxString& + { + if( pathNameCache.count( aPath ) ) + return pathNameCache.at( aPath ); + + pathNameCache[aPath] = aPath.AsString(); + return pathNameCache[aPath]; + }; + for( size_t i = 0; i < symbolInstances.GetCount(); i++ ) { // The instance paths are stored in the file sans root path so the comparison @@ -780,9 +794,9 @@ void SCH_SHEET_LIST::UpdateSymbolInstances( wxString path = symbolInstances[i].GetPath(); auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(), - [ path ]( const COMPONENT_INSTANCE_REFERENCE& r ) -> bool + [ path, &getName ]( const COMPONENT_INSTANCE_REFERENCE& r ) -> bool { - return path == r.m_Path.AsString(); + return path == getName( r.m_Path ); } );