More optimization in project rescue.

This commit is contained in:
jean-pierre charras 2017-03-10 10:31:50 +01:00
parent c523ba45e1
commit 0be56451b1
2 changed files with 36 additions and 14 deletions

View File

@ -276,7 +276,10 @@ public:
LIB_ID id( wxEmptyString, part_name ); LIB_ID id( wxEmptyString, part_name );
case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( id ); 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() ) ) if( case_sensitive_match || !( case_insensitive_matches.size() ) )
@ -285,6 +288,7 @@ public:
RESCUE_CASE_CANDIDATE candidate( RESCUE_CASE_CANDIDATE candidate(
part_name, case_insensitive_matches[0]->GetName(), part_name, case_insensitive_matches[0]->GetName(),
case_insensitive_matches[0]->GetPart() ); case_insensitive_matches[0]->GetPart() );
candidate_map[part_name] = candidate; candidate_map[part_name] = candidate;
} }
@ -379,20 +383,22 @@ public:
cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true ); cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true );
LIB_ID id( wxEmptyString, part_name ); LIB_ID id( wxEmptyString, part_name );
lib_match = aRescuer.GetLibs()->FindLibPart( id ); 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 // Now, dump the map into aCandidates

View File

@ -35,6 +35,7 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <wx/log.h>
/** /**
* The class PROF_COUNTER is a small class to help profiling. * 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; 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<double, std::milli> elapsed = display_stoptime - m_starttime;
wxString msg;
msg << m_name << " took " << elapsed.count() << " ms.";
wxLogMessage( msg );
}
/** /**
* @return the elapsed time in ms * @return the elapsed time in ms
*/ */