Fix loop variable copy in for-range loop, use const reference instead

This commit is contained in:
Camille 2017-09-24 20:11:58 +02:00 committed by Wayne Stambaugh
parent 5c4f8abd24
commit f5f7ba4746
17 changed files with 30 additions and 30 deletions

View File

@ -187,7 +187,7 @@ bool S3D_FILENAME_RESOLVER::createPathList( void )
if( GetKicadPaths( epaths ) ) if( GetKicadPaths( epaths ) )
{ {
for( auto i : epaths ) for( const auto& i : epaths )
{ {
wxString pathVal = ExpandEnvVarSubstitutions( i ); wxString pathVal = ExpandEnvVarSubstitutions( i );

View File

@ -341,7 +341,7 @@ void DLG_3D_PATH_CONFIG::updateEnvVars( void )
int j = 0; int j = 0;
for( auto i : epaths ) for( const auto& i : epaths )
{ {
wxString val = ExpandEnvVarSubstitutions( i ); wxString val = ExpandEnvVarSubstitutions( i );
m_EnvVars->SetCellValue( j, 0, i ); m_EnvVars->SetCellValue( j, 0, i );

View File

@ -103,7 +103,7 @@ void WX_HTML_REPORT_PANEL::refreshView()
{ {
wxString html; wxString html;
for( REPORT_LINE l : m_report ) for( const REPORT_LINE& l : m_report )
{ {
html += generateHtml( l ); html += generateHtml( l );
} }
@ -271,7 +271,7 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
return; return;
} }
for( REPORT_LINE l : m_report ) for( const REPORT_LINE& l : m_report )
{ {
f.Write( generatePlainText( l ) ); f.Write( generatePlainText( l ) );
} }

View File

@ -155,7 +155,7 @@ const std::string TOOL_EVENT_LIST::Format() const
{ {
std::string s; std::string s;
for( TOOL_EVENT e : m_events ) for( const TOOL_EVENT& e : m_events )
s += e.Format() + " "; s += e.Format() + " ";
return s; return s;

View File

@ -120,7 +120,7 @@ void CMP_TREE_MODEL_ADAPTER_BASE::AddLibrariesWithProgress(
unsigned int ii = 0; unsigned int ii = 0;
for( auto nickname : aNicknames ) for( const auto& nickname : aNicknames )
{ {
if( prg ) if( prg )
prg->Update( ii++, wxString::Format( _( "Loading library \"%s\"" ), nickname ) ); prg->Update( ii++, wxString::Format( _( "Loading library \"%s\"" ), nickname ) );

View File

@ -198,7 +198,7 @@ void DIALOG_BOM_EDITOR::ApplyAllChanges()
ITEM_PICKER picker; ITEM_PICKER picker;
// Iterate through each of the components that were changed // Iterate through each of the components that were changed
for( auto ref : changed ) for( const auto& ref : changed )
{ {
// Extract the SCH_COMPONENT* object // Extract the SCH_COMPONENT* object
auto cmp = ref.GetComp(); auto cmp = ref.GetComp();

View File

@ -501,7 +501,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
newScreens.GetLibNicknames( names ); newScreens.GetLibNicknames( names );
wxArrayString newLibNames; wxArrayString newLibNames;
for( auto name : names ) for( const auto& name : names )
{ {
if( !Prj().SchSymbolLibTable()->HasLibrary( name ) ) if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
newLibNames.Add( name ); newLibNames.Add( name );
@ -526,7 +526,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
if( !table.IsEmpty() ) if( !table.IsEmpty() )
{ {
for( auto libName : newLibNames ) for( const auto& libName : newLibNames )
{ {
if( !table.HasLibrary( libName ) ) if( !table.HasLibrary( libName ) )
continue; continue;
@ -602,7 +602,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
SCH_SCREEN* newScreen = newSheet->GetScreen(); SCH_SCREEN* newScreen = newSheet->GetScreen();
wxCHECK_MSG( newScreen, false, "No screen defined for imported sheet." ); 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 ); SCH_SHEET* renamedSheet = newScreen->GetSheet( duplicateName );

View File

@ -69,7 +69,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
aFormatter->Print( 0, ".title KiCad schematic\n" ); aFormatter->Print( 0, ".title KiCad schematic\n" );
// Write .include directives // Write .include directives
for( auto lib : m_libraries ) for( const auto& lib : m_libraries )
{ {
wxString full_path; wxString full_path;

View File

@ -207,7 +207,7 @@ void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin )
bool SCH_SHEET::HasPin( const wxString& aName ) 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 ) if( pin.GetText().CmpNoCase( aName ) == 0 )
return true; return true;
@ -219,7 +219,7 @@ bool SCH_SHEET::HasPin( const wxString& aName )
bool SCH_SHEET::IsVerticalOrientation() const bool SCH_SHEET::IsVerticalOrientation() const
{ {
for( SCH_SHEET_PIN pin : m_pins ) for( const SCH_SHEET_PIN& pin : m_pins )
{ {
if( pin.GetEdge() > 1 ) if( pin.GetEdge() > 1 )
return true; return true;
@ -230,7 +230,7 @@ bool SCH_SHEET::IsVerticalOrientation() const
bool SCH_SHEET::HasUndefinedPins() 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. */ /* Search the schematic for a hierarchical label corresponding to this sheet label. */
EDA_ITEM* DrawStruct = m_screen->GetDrawItems(); EDA_ITEM* DrawStruct = m_screen->GetDrawItems();

View File

@ -91,7 +91,7 @@ wxString SCH_BASE_FRAME::SelectLibraryFromList()
std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs(); std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
// Conversion from wxArrayString to vector of ArrayString // Conversion from wxArrayString to vector of ArrayString
for( auto name : libNicknames ) for( const auto& name : libNicknames )
{ {
wxArrayString item; wxArrayString item;

View File

@ -240,7 +240,7 @@ int SYMBOL_LIB_TABLE::GetModifyHash()
int hash = 0; int hash = 0;
std::vector< wxString > libNames = GetLogicalLibs(); std::vector< wxString > libNames = GetLogicalLibs();
for( auto libName : libNames ) for( const auto& libName : libNames )
{ {
const SYMBOL_LIB_TABLE_ROW* row = FindRow( libName ); const SYMBOL_LIB_TABLE_ROW* row = FindRow( libName );

View File

@ -469,7 +469,7 @@ bool LIB_VIEW_FRAME::ReCreateListLib()
wxArrayString libNames; wxArrayString libNames;
for( auto name : libs ) for( const auto& name : libs )
libNames.Add( name ); libNames.Add( name );
m_libList->Append( libNames ); m_libList->Append( libNames );

View File

@ -351,7 +351,7 @@ void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate( wxCommandEvent& event )
{ {
std::vector< wxFileName > overwrittenFiles; std::vector< wxFileName > overwrittenFiles;
for( auto file : destFiles ) for( const auto& file : destFiles )
{ {
if( file.FileExists() ) if( file.FileExists() )
overwrittenFiles.push_back( file ); overwrittenFiles.push_back( file );
@ -361,7 +361,7 @@ void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate( wxCommandEvent& event )
{ {
wxString extendedMsg = _( "Overwriting files:" ) + "\n"; wxString extendedMsg = _( "Overwriting files:" ) + "\n";
for( auto file : overwrittenFiles ) for( const auto& file : overwrittenFiles )
{ {
extendedMsg += "\n" + file.GetFullName(); extendedMsg += "\n" + file.GetFullName();
} }

View File

@ -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 // Find the template file name base. this is the name of the .pro template file
wxString basename; wxString basename;
for( auto file : srcFiles ) for( const auto& file : srcFiles )
{ {
if( file.GetExt() == wxT( "pro" ) ) 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; wxFileName destFile = file;

View File

@ -365,7 +365,7 @@ bool TRACKS_CLEANER::testTrackEndpointDangling( TRACK* aTrack, ENDPOINT_T aEndPo
auto anchors = citem->Anchors(); auto anchors = citem->Anchors();
for( auto anchor : anchors ) for( const auto& anchor : anchors )
{ {
if( anchor->Pos() == endpoint && anchor->IsDangling() ) if( anchor->Pos() == endpoint && anchor->IsDangling() )
return true; return true;

View File

@ -797,7 +797,7 @@ void CN_CONNECTIVITY_ALGO::Build( const std::vector<BOARD_ITEM*>& aItems )
void CN_CONNECTIVITY_ALGO::propagateConnections() void CN_CONNECTIVITY_ALGO::propagateConnections()
{ {
for( auto cluster : m_connClusters ) for( const auto& cluster : m_connClusters )
{ {
if( cluster->IsConflicting() ) if( cluster->IsConflicting() )
{ {
@ -862,7 +862,7 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std
m_connClusters = SearchClusters( CSM_CONNECTIVITY_CHECK ); m_connClusters = SearchClusters( CSM_CONNECTIVITY_CHECK );
for( auto cluster : m_connClusters ) for( const auto& cluster : m_connClusters )
{ {
if( cluster->Contains( aZone ) && cluster->IsOrphaned() ) if( cluster->Contains( aZone ) && cluster->IsOrphaned() )
{ {
@ -897,7 +897,7 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( std::vector<CN_ZONE_ISOLAT
if( zone.m_zone->GetFilledPolysList().IsEmpty() ) if( zone.m_zone->GetFilledPolysList().IsEmpty() )
continue; continue;
for( auto cluster : m_connClusters ) for( const auto& cluster : m_connClusters )
{ {
if( cluster->Contains( zone.m_zone ) && cluster->IsOrphaned() ) if( cluster->Contains( zone.m_zone ) && cluster->IsOrphaned() )
{ {
@ -1051,16 +1051,16 @@ void CN_CONNECTIVITY_ALGO::ForEachItem( const std::function<void( CN_ITEM& )>& a
void CN_CONNECTIVITY_ALGO::ForEachAnchor( const std::function<void( CN_ANCHOR& )>& aFunc ) void CN_CONNECTIVITY_ALGO::ForEachAnchor( const std::function<void( CN_ANCHOR& )>& aFunc )
{ {
for( auto anchor : m_padList.Anchors() ) for( const auto& anchor : m_padList.Anchors() )
aFunc( *anchor ); aFunc( *anchor );
for( auto anchor : m_viaList.Anchors() ) for( const auto& anchor : m_viaList.Anchors() )
aFunc( *anchor ); aFunc( *anchor );
for( auto anchor : m_trackList.Anchors() ) for( const auto& anchor : m_trackList.Anchors() )
aFunc( *anchor ); aFunc( *anchor );
for( auto anchor : m_zoneList.Anchors() ) for( const auto& anchor : m_zoneList.Anchors() )
aFunc( *anchor ); aFunc( *anchor );
} }

View File

@ -309,7 +309,7 @@ const DIFF_PAIR DP_GATEWAY::Entry() const
void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries, void DP_GATEWAYS::BuildOrthoProjections( DP_GATEWAYS& aEntries,
const VECTOR2I& aCursorPos, int aOrthoScore ) 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 ); VECTOR2I midpoint( ( g.AnchorP() + g.AnchorN() ) / 2 );
SEG guide_s( midpoint, midpoint + VECTOR2I( 1, 0 ) ); SEG guide_s( midpoint, midpoint + VECTOR2I( 1, 0 ) );