Cache sheet path to string conversion in UpdateSymbolInstances
Profiling of large designs (with many hierarchical sheets) showed that this can be a huge (4x) speed up to schematic loading times.
This commit is contained in:
parent
af24a5d5a7
commit
fc92fb076e
|
@ -43,6 +43,7 @@
|
|||
#include <sch_component.h>
|
||||
#include <schematic.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <profile.h>
|
||||
#include <project_rescue.h>
|
||||
#include <reporter.h>
|
||||
#include <eeschema_config.h>
|
||||
|
@ -244,6 +245,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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<wxString>& aFileSet, in
|
|||
m_infoBar->ShowMessage( "Schematic file is read only.", wxICON_WARNING );
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
openFiles.Show();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -773,6 +773,20 @@ void SCH_SHEET_LIST::UpdateSymbolInstances(
|
|||
|
||||
GetComponents( symbolInstances, true, true );
|
||||
|
||||
std::map<KIID_PATH, wxString> 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 );
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue