From 0be56451b180162af3dd726af4633b8fb1e66b87 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 10 Mar 2017 10:31:50 +0100 Subject: [PATCH] More optimization in project rescue. --- eeschema/project_rescue.cpp | 34 ++++++++++++++++++++-------------- include/profile.h | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 22fa0d437f..5e74871dc7 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -276,7 +276,10 @@ public: LIB_ID id( wxEmptyString, part_name ); case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( id ); - aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name ); + + if( !case_sensitive_match ) + // the case sensitive match failed. Try a case insensitive match + aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name ); } if( case_sensitive_match || !( case_insensitive_matches.size() ) ) @@ -285,6 +288,7 @@ public: RESCUE_CASE_CANDIDATE candidate( part_name, case_insensitive_matches[0]->GetName(), case_insensitive_matches[0]->GetPart() ); + candidate_map[part_name] = candidate; } @@ -379,20 +383,22 @@ public: cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true ); LIB_ID id( wxEmptyString, part_name ); lib_match = aRescuer.GetLibs()->FindLibPart( id ); + + // Test whether there is a conflict + if( !cache_match || !lib_match ) + continue; + + if( !cache_match->PinsConflictWith( *lib_match, /* aTestNums */ true, + /* aTestNames */ true, /* aTestType */ true, /* aTestOrientation */ true, + /* aTestLength */ false )) + continue; + + RESCUE_CACHE_CANDIDATE candidate( + part_name, part_name + part_name_suffix, + cache_match, lib_match ); + + candidate_map[part_name] = candidate; } - - // Test whether there is a conflict - if( !cache_match || !lib_match ) - continue; - if( !cache_match->PinsConflictWith( *lib_match, /* aTestNums */ true, - /* aTestNames */ true, /* aTestType */ true, /* aTestOrientation */ true, - /* aTestLength */ false )) - continue; - - RESCUE_CACHE_CANDIDATE candidate( - part_name, part_name + part_name_suffix, - cache_match, lib_match ); - candidate_map[part_name] = candidate; } // Now, dump the map into aCandidates diff --git a/include/profile.h b/include/profile.h index a907436925..c488f4c987 100644 --- a/include/profile.h +++ b/include/profile.h @@ -35,6 +35,7 @@ #include #include #include +#include /** * The class PROF_COUNTER is a small class to help profiling. @@ -99,6 +100,21 @@ public: std::cerr << m_name << " took " << elapsed.count() << " milliseconds." << std::endl; } + /** + * Show the elapsed time (in ms) in a wxLogMessage window. + */ + void ShowDlg() + { + TIME_POINT display_stoptime = m_running ? + std::chrono::high_resolution_clock::now() : + m_stoptime; + + std::chrono::duration elapsed = display_stoptime - m_starttime; + wxString msg; + msg << m_name << " took " << elapsed.count() << " ms."; + wxLogMessage( msg ); + } + /** * @return the elapsed time in ms */