From 8235843d01f9c06100241ed1d3d18b824d06af07 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 9 Jun 2025 15:52:44 +0100 Subject: [PATCH] Don't pass large structures by value. --- common/background_jobs_monitor.cpp | 9 ++++----- eeschema/sch_reference_list.cpp | 22 +++++++++++----------- eeschema/sch_reference_list.h | 14 +++++++------- include/background_jobs_monitor.h | 4 ++-- pcbnew/connectivity/connectivity_algo.cpp | 2 +- pcbnew/connectivity/connectivity_algo.h | 2 +- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/common/background_jobs_monitor.cpp b/common/background_jobs_monitor.cpp index 470789a2bd..179773f56e 100644 --- a/common/background_jobs_monitor.cpp +++ b/common/background_jobs_monitor.cpp @@ -173,9 +173,10 @@ private: BACKGROUND_JOB_REPORTER::BACKGROUND_JOB_REPORTER( BACKGROUND_JOBS_MONITOR* aMonitor, - std::shared_ptr aJob ) : + const std::shared_ptr& aJob ) : PROGRESS_REPORTER_BASE( 1 ), - m_monitor( aMonitor ), m_job( aJob ) + m_monitor( aMonitor ), + m_job( aJob ) { } @@ -305,10 +306,8 @@ void BACKGROUND_JOBS_MONITOR::ShowList( wxWindow* aParent, wxPoint aPos ) std::shared_lock lock( m_mutex, std::try_to_lock ); - for( std::shared_ptr job : m_jobs ) - { + for( const std::shared_ptr& job : m_jobs ) list->Add( job ); - } lock.unlock(); diff --git a/eeschema/sch_reference_list.cpp b/eeschema/sch_reference_list.cpp index 9923646085..f36c5900dc 100644 --- a/eeschema/sch_reference_list.cpp +++ b/eeschema/sch_reference_list.cpp @@ -404,12 +404,12 @@ void SCH_REFERENCE_LIST::ReannotateDuplicates( const SCH_REFERENCE_LIST& aAdditi } -void SCH_REFERENCE_LIST::AnnotateByOptions( ANNOTATE_ORDER_T aSortOption, - ANNOTATE_ALGO_T aAlgoOption, - int aStartNumber, - SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, - const SCH_REFERENCE_LIST& aAdditionalRefs, - bool aStartAtCurrent ) +void SCH_REFERENCE_LIST::AnnotateByOptions( ANNOTATE_ORDER_T aSortOption, + ANNOTATE_ALGO_T aAlgoOption, + int aStartNumber, + const SCH_MULTI_UNIT_REFERENCE_MAP& aLockedUnitMap, + const SCH_REFERENCE_LIST& aAdditionalRefs, + bool aStartAtCurrent ) { switch( aSortOption ) { @@ -447,7 +447,7 @@ void SCH_REFERENCE_LIST::AnnotateByOptions( ANNOTATE_ORDER_T aSortOp void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, - SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, + const SCH_MULTI_UNIT_REFERENCE_MAP& aLockedUnitMap, const SCH_REFERENCE_LIST& aAdditionalRefs, bool aStartAtCurrent ) { if ( m_flatList.size() == 0 ) @@ -508,15 +508,15 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int continue; // Check whether this symbol is in aLockedUnitMap. - SCH_REFERENCE_LIST* lockedList = nullptr; + const SCH_REFERENCE_LIST* lockedList = nullptr; - for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : aLockedUnitMap ) + for( const SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : aLockedUnitMap ) { unsigned n_refs = pair.second.GetCount(); for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI ) { - SCH_REFERENCE &thisRef = pair.second[thisRefI]; + const SCH_REFERENCE &thisRef = pair.second[thisRefI]; if( thisRef.IsSameInstance( ref_unit ) ) { @@ -583,7 +583,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int for( unsigned lockedRefI = 0; lockedRefI < n_refs; ++lockedRefI ) { - SCH_REFERENCE& lockedRef = ( *lockedList )[lockedRefI]; + const SCH_REFERENCE& lockedRef = ( *lockedList )[lockedRefI]; if( lockedRef.IsSameInstance( ref_unit ) ) { diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h index 196164337b..99f835cb26 100644 --- a/eeschema/sch_reference_list.h +++ b/eeschema/sch_reference_list.h @@ -405,12 +405,12 @@ public: * @param aStartAtCurrent Use m_numRef for each reference as the start number (overrides * aStartNumber) */ - void AnnotateByOptions( enum ANNOTATE_ORDER_T aSortOption, - enum ANNOTATE_ALGO_T aAlgoOption, - int aStartNumber, - SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, - const SCH_REFERENCE_LIST& aAdditionalRefs, - bool aStartAtCurrent ); + void AnnotateByOptions( enum ANNOTATE_ORDER_T aSortOption, + enum ANNOTATE_ALGO_T aAlgoOption, + int aStartNumber, + const SCH_MULTI_UNIT_REFERENCE_MAP& aLockedUnitMap, + const SCH_REFERENCE_LIST& aAdditionalRefs, + bool aStartAtCurrent ); /** * Set the reference designators in the list that have not been annotated. @@ -434,7 +434,7 @@ public: aStartNumber) */ void Annotate( bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, - SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, + const SCH_MULTI_UNIT_REFERENCE_MAP& aLockedUnitMap, const SCH_REFERENCE_LIST& aAdditionalRefs, bool aStartAtCurrent = false ); /** diff --git a/include/background_jobs_monitor.h b/include/background_jobs_monitor.h index eb3fc491fe..adf944cdf8 100644 --- a/include/background_jobs_monitor.h +++ b/include/background_jobs_monitor.h @@ -45,8 +45,8 @@ class wxCloseEvent; class KICOMMON_API BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE { public: - BACKGROUND_JOB_REPORTER( BACKGROUND_JOBS_MONITOR* aMonitor, - std::shared_ptr aJob ); + BACKGROUND_JOB_REPORTER( BACKGROUND_JOBS_MONITOR* aMonitor, + const std::shared_ptr& aJob ); void SetTitle( const wxString& aTitle ) override { diff --git a/pcbnew/connectivity/connectivity_algo.cpp b/pcbnew/connectivity/connectivity_algo.cpp index e99ea29834..e3dcaa1cda 100644 --- a/pcbnew/connectivity/connectivity_algo.cpp +++ b/pcbnew/connectivity/connectivity_algo.cpp @@ -551,7 +551,7 @@ void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter ) } -void CN_CONNECTIVITY_ALGO::LocalBuild( std::shared_ptr aGlobalConnectivity, +void CN_CONNECTIVITY_ALGO::LocalBuild( const std::shared_ptr& aGlobalConnectivity, const std::vector& aLocalItems ) { m_isLocal = true; diff --git a/pcbnew/connectivity/connectivity_algo.h b/pcbnew/connectivity/connectivity_algo.h index 3bf93acb1b..56ace5d263 100644 --- a/pcbnew/connectivity/connectivity_algo.h +++ b/pcbnew/connectivity/connectivity_algo.h @@ -218,7 +218,7 @@ public: } void Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter = nullptr ); - void LocalBuild( std::shared_ptr aGlobalConnectivity, + void LocalBuild( const std::shared_ptr& aGlobalConnectivity, const std::vector& aLocalItems ); void Clear();