From f5f7ba4746b2f1622dc6bc47a3625ad8cf234f7b Mon Sep 17 00:00:00 2001 From: Camille Date: Sun, 24 Sep 2017 20:11:58 +0200 Subject: [PATCH] Fix loop variable copy in for-range loop, use const reference instead --- 3d-viewer/3d_cache/3d_filename_resolver.cpp | 2 +- 3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp | 2 +- common/dialogs/wx_html_report_panel.cpp | 4 ++-- common/tool/tool_event.cpp | 2 +- eeschema/cmp_tree_model_adapter_base.cpp | 2 +- eeschema/dialogs/dialog_bom_editor.cpp | 2 +- eeschema/files-io.cpp | 6 +++--- .../netlist_exporters/netlist_exporter_pspice.cpp | 2 +- eeschema/sch_sheet.cpp | 6 +++--- eeschema/selpart.cpp | 2 +- eeschema/symbol_lib_table.cpp | 2 +- eeschema/viewlib_frame.cpp | 2 +- kicad/prjconfig.cpp | 4 ++-- kicad/project_template.cpp | 4 ++-- pcbnew/clean.cpp | 2 +- pcbnew/connectivity_algo.cpp | 14 +++++++------- pcbnew/router/pns_diff_pair.cpp | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/3d-viewer/3d_cache/3d_filename_resolver.cpp b/3d-viewer/3d_cache/3d_filename_resolver.cpp index 2e60001704..82ff7dfc7d 100644 --- a/3d-viewer/3d_cache/3d_filename_resolver.cpp +++ b/3d-viewer/3d_cache/3d_filename_resolver.cpp @@ -187,7 +187,7 @@ bool S3D_FILENAME_RESOLVER::createPathList( void ) if( GetKicadPaths( epaths ) ) { - for( auto i : epaths ) + for( const auto& i : epaths ) { wxString pathVal = ExpandEnvVarSubstitutions( i ); diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp index ceb85e9b44..19c9ed9c3a 100644 --- a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp +++ b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp @@ -341,7 +341,7 @@ void DLG_3D_PATH_CONFIG::updateEnvVars( void ) int j = 0; - for( auto i : epaths ) + for( const auto& i : epaths ) { wxString val = ExpandEnvVarSubstitutions( i ); m_EnvVars->SetCellValue( j, 0, i ); diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp index 57937b6dbf..6ed282678f 100644 --- a/common/dialogs/wx_html_report_panel.cpp +++ b/common/dialogs/wx_html_report_panel.cpp @@ -103,7 +103,7 @@ void WX_HTML_REPORT_PANEL::refreshView() { wxString html; - for( REPORT_LINE l : m_report ) + for( const REPORT_LINE& l : m_report ) { html += generateHtml( l ); } @@ -271,7 +271,7 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event ) return; } - for( REPORT_LINE l : m_report ) + for( const REPORT_LINE& l : m_report ) { f.Write( generatePlainText( l ) ); } diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index 044feffb67..6bc2763062 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -155,7 +155,7 @@ const std::string TOOL_EVENT_LIST::Format() const { std::string s; - for( TOOL_EVENT e : m_events ) + for( const TOOL_EVENT& e : m_events ) s += e.Format() + " "; return s; diff --git a/eeschema/cmp_tree_model_adapter_base.cpp b/eeschema/cmp_tree_model_adapter_base.cpp index 0e95de0126..041d02ca0e 100644 --- a/eeschema/cmp_tree_model_adapter_base.cpp +++ b/eeschema/cmp_tree_model_adapter_base.cpp @@ -120,7 +120,7 @@ void CMP_TREE_MODEL_ADAPTER_BASE::AddLibrariesWithProgress( unsigned int ii = 0; - for( auto nickname : aNicknames ) + for( const auto& nickname : aNicknames ) { if( prg ) prg->Update( ii++, wxString::Format( _( "Loading library \"%s\"" ), nickname ) ); diff --git a/eeschema/dialogs/dialog_bom_editor.cpp b/eeschema/dialogs/dialog_bom_editor.cpp index 3d1b0323cc..7dd8b6a01d 100644 --- a/eeschema/dialogs/dialog_bom_editor.cpp +++ b/eeschema/dialogs/dialog_bom_editor.cpp @@ -198,7 +198,7 @@ void DIALOG_BOM_EDITOR::ApplyAllChanges() ITEM_PICKER picker; // Iterate through each of the components that were changed - for( auto ref : changed ) + for( const auto& ref : changed ) { // Extract the SCH_COMPONENT* object auto cmp = ref.GetComp(); diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index e334313232..a614042905 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -501,7 +501,7 @@ bool SCH_EDIT_FRAME::AppendSchematic() newScreens.GetLibNicknames( names ); wxArrayString newLibNames; - for( auto name : names ) + for( const auto& name : names ) { if( !Prj().SchSymbolLibTable()->HasLibrary( name ) ) newLibNames.Add( name ); @@ -526,7 +526,7 @@ bool SCH_EDIT_FRAME::AppendSchematic() if( !table.IsEmpty() ) { - for( auto libName : newLibNames ) + for( const auto& libName : newLibNames ) { if( !table.HasLibrary( libName ) ) continue; @@ -602,7 +602,7 @@ bool SCH_EDIT_FRAME::AppendSchematic() SCH_SCREEN* newScreen = newSheet->GetScreen(); wxCHECK_MSG( newScreen, false, "No screen defined for imported sheet." ); - for( auto duplicateName : duplicateSheetNames ) + for( const auto& duplicateName : duplicateSheetNames ) { SCH_SHEET* renamedSheet = newScreen->GetSheet( duplicateName ); diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index e67f715151..18a5c0c5d3 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -69,7 +69,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl aFormatter->Print( 0, ".title KiCad schematic\n" ); // Write .include directives - for( auto lib : m_libraries ) + for( const auto& lib : m_libraries ) { wxString full_path; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 1276964898..91d1237dc9 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -207,7 +207,7 @@ void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin ) bool SCH_SHEET::HasPin( const wxString& aName ) { - for( SCH_SHEET_PIN pin : m_pins ) + for( const SCH_SHEET_PIN& pin : m_pins ) { if( pin.GetText().CmpNoCase( aName ) == 0 ) return true; @@ -219,7 +219,7 @@ bool SCH_SHEET::HasPin( const wxString& aName ) bool SCH_SHEET::IsVerticalOrientation() const { - for( SCH_SHEET_PIN pin : m_pins ) + for( const SCH_SHEET_PIN& pin : m_pins ) { if( pin.GetEdge() > 1 ) return true; @@ -230,7 +230,7 @@ bool SCH_SHEET::IsVerticalOrientation() const bool SCH_SHEET::HasUndefinedPins() { - for( SCH_SHEET_PIN pin : m_pins ) + for( const SCH_SHEET_PIN& pin : m_pins ) { /* Search the schematic for a hierarchical label corresponding to this sheet label. */ EDA_ITEM* DrawStruct = m_screen->GetDrawItems(); diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index d4d6bf88da..b038ab8c0d 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -91,7 +91,7 @@ wxString SCH_BASE_FRAME::SelectLibraryFromList() std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs(); // Conversion from wxArrayString to vector of ArrayString - for( auto name : libNicknames ) + for( const auto& name : libNicknames ) { wxArrayString item; diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp index 642a989679..32e001101f 100644 --- a/eeschema/symbol_lib_table.cpp +++ b/eeschema/symbol_lib_table.cpp @@ -240,7 +240,7 @@ int SYMBOL_LIB_TABLE::GetModifyHash() int hash = 0; std::vector< wxString > libNames = GetLogicalLibs(); - for( auto libName : libNames ) + for( const auto& libName : libNames ) { const SYMBOL_LIB_TABLE_ROW* row = FindRow( libName ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 7a2cf00077..02d4ba03b7 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -469,7 +469,7 @@ bool LIB_VIEW_FRAME::ReCreateListLib() wxArrayString libNames; - for( auto name : libs ) + for( const auto& name : libs ) libNames.Add( name ); m_libList->Append( libNames ); diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index ee0f01cd2d..ad16fadc3b 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -351,7 +351,7 @@ void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate( wxCommandEvent& event ) { std::vector< wxFileName > overwrittenFiles; - for( auto file : destFiles ) + for( const auto& file : destFiles ) { if( file.FileExists() ) overwrittenFiles.push_back( file ); @@ -361,7 +361,7 @@ void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate( wxCommandEvent& event ) { wxString extendedMsg = _( "Overwriting files:" ) + "\n"; - for( auto file : overwrittenFiles ) + for( const auto& file : overwrittenFiles ) { extendedMsg += "\n" + file.GetFullName(); } diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp index f541ccf07b..af82fc824d 100644 --- a/kicad/project_template.cpp +++ b/kicad/project_template.cpp @@ -123,7 +123,7 @@ size_t PROJECT_TEMPLATE::GetDestinationFiles( const wxFileName& aNewProjectPath, // Find the template file name base. this is the name of the .pro template file wxString basename; - for( auto file : srcFiles ) + for( const auto& file : srcFiles ) { if( file.GetExt() == wxT( "pro" ) ) { @@ -132,7 +132,7 @@ size_t PROJECT_TEMPLATE::GetDestinationFiles( const wxFileName& aNewProjectPath, } } - for( auto file : srcFiles ) + for( const auto& file : srcFiles ) { wxFileName destFile = file; diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index bcfd5b7d94..eb4494c793 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -365,7 +365,7 @@ bool TRACKS_CLEANER::testTrackEndpointDangling( TRACK* aTrack, ENDPOINT_T aEndPo auto anchors = citem->Anchors(); - for( auto anchor : anchors ) + for( const auto& anchor : anchors ) { if( anchor->Pos() == endpoint && anchor->IsDangling() ) return true; diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp index 88913b2bd2..c00fd04470 100644 --- a/pcbnew/connectivity_algo.cpp +++ b/pcbnew/connectivity_algo.cpp @@ -797,7 +797,7 @@ void CN_CONNECTIVITY_ALGO::Build( const std::vector& aItems ) void CN_CONNECTIVITY_ALGO::propagateConnections() { - for( auto cluster : m_connClusters ) + for( const auto& cluster : m_connClusters ) { if( cluster->IsConflicting() ) { @@ -862,7 +862,7 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std m_connClusters = SearchClusters( CSM_CONNECTIVITY_CHECK ); - for( auto cluster : m_connClusters ) + for( const auto& cluster : m_connClusters ) { if( cluster->Contains( aZone ) && cluster->IsOrphaned() ) { @@ -897,7 +897,7 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( std::vectorGetFilledPolysList().IsEmpty() ) continue; - for( auto cluster : m_connClusters ) + for( const auto& cluster : m_connClusters ) { if( cluster->Contains( zone.m_zone ) && cluster->IsOrphaned() ) { @@ -1051,16 +1051,16 @@ void CN_CONNECTIVITY_ALGO::ForEachItem( const std::function& a void CN_CONNECTIVITY_ALGO::ForEachAnchor( const std::function& aFunc ) { - for( auto anchor : m_padList.Anchors() ) + for( const auto& anchor : m_padList.Anchors() ) aFunc( *anchor ); - for( auto anchor : m_viaList.Anchors() ) + for( const auto& anchor : m_viaList.Anchors() ) aFunc( *anchor ); - for( auto anchor : m_trackList.Anchors() ) + for( const auto& anchor : m_trackList.Anchors() ) aFunc( *anchor ); - for( auto anchor : m_zoneList.Anchors() ) + for( const auto& anchor : m_zoneList.Anchors() ) aFunc( *anchor ); } diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 67f93c0d18..e603f196e2 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -309,7 +309,7 @@ const DIFF_PAIR DP_GATEWAY::Entry() const void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries, const VECTOR2I& aCursorPos, int aOrthoScore ) { - for( DP_GATEWAY g : aEntries.Gateways() ) + for( const DP_GATEWAY& g : aEntries.Gateways() ) { VECTOR2I midpoint( ( g.AnchorP() + g.AnchorN() ) / 2 ); SEG guide_s( midpoint, midpoint + VECTOR2I( 1, 0 ) );