diff --git a/3d-viewer/3d_cache/sg/sg_helpers.cpp b/3d-viewer/3d_cache/sg/sg_helpers.cpp index 60103ea811..0082bfde07 100644 --- a/3d-viewer/3d_cache/sg/sg_helpers.cpp +++ b/3d-viewer/3d_cache/sg/sg_helpers.cpp @@ -49,7 +49,7 @@ void S3D::FormatFloat( std::string& result, double value ) result = out.str(); - size_t p = result.find( "." ); + size_t p = result.find( '.' ); // trim trailing 0 if appropriate diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp index dc60e7478b..aadf3f22bc 100644 --- a/common/dialogs/wx_html_report_panel.cpp +++ b/common/dialogs/wx_html_report_panel.cpp @@ -104,13 +104,13 @@ void WX_HTML_REPORT_PANEL::Flush( bool aSort ) }); } - for( auto line : m_reportHead ) + for( const auto& line : m_reportHead ) html += generateHtml( line ); - for( auto line : m_report ) + for( const auto& line : m_report ) html += generateHtml( line ); - for( auto line : m_reportTail ) + for( const auto& line : m_reportTail ) html += generateHtml( line ); m_htmlView->SetPage( addHeader( html ) ); diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp index 867cf47f49..0e7a85366b 100644 --- a/common/plotters/DXF_plotter.cpp +++ b/common/plotters/DXF_plotter.cpp @@ -615,11 +615,12 @@ void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int { std::vector cornerList; SHAPE_POLY_SET outlineBuffer; - TransformOvalToPolygon( outlineBuffer, aStart, aEnd, aWidth, GetPlotterArcHighDef()); - const SHAPE_LINE_CHAIN& path = outlineBuffer.COutline(0 ); + TransformOvalToPolygon( outlineBuffer, aStart, aEnd, aWidth, GetPlotterArcHighDef() ); + const SHAPE_LINE_CHAIN& path = outlineBuffer.COutline( 0 ); + cornerList.reserve( path.PointCount() ); for( int jj = 0; jj < path.PointCount(); jj++ ) - cornerList.emplace_back( path.CPoint( jj ).x , path.CPoint( jj ).y ); + cornerList.emplace_back( path.CPoint( jj ).x, path.CPoint( jj ).y ); // Ensure the polygon is closed if( cornerList[0] != cornerList[cornerList.size() - 1] ) diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 88648bf9c7..8b46ad44b9 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -962,10 +962,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCo // TODO: use Aperture macro and flash it // polygon corners list - std::vector< wxPoint > cornerList; - - for( int ii = 0; ii < 4; ii++ ) - cornerList.push_back( aCorners[ii] ); + std::vector cornerList = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] }; // Draw the polygon and fill the interior as required for( unsigned ii = 0; ii < 4; ii++ ) diff --git a/common/plotters/HPGL_plotter.cpp b/common/plotters/HPGL_plotter.cpp index 639994e446..284338cf1b 100644 --- a/common/plotters/HPGL_plotter.cpp +++ b/common/plotters/HPGL_plotter.cpp @@ -645,8 +645,9 @@ void HPGL_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSiz aCornerRadius, 0.0, 0, GetPlotterArcHighDef() ); // TransformRoundRectToPolygon creates only one convex polygon - std::vector< wxPoint > cornerList; - SHAPE_LINE_CHAIN& poly = outline.Outline( 0 ); + std::vector cornerList; + SHAPE_LINE_CHAIN& poly = outline.Outline( 0 ); + cornerList.reserve( poly.PointCount() ); for( int ii = 0; ii < poly.PointCount(); ++ii ) cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y ); diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index 3a91444ed9..95e1a88f11 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -206,6 +206,7 @@ void PSLIKE_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS std::vector< wxPoint > cornerList; // TransformRoundRectToPolygon creates only one convex polygon SHAPE_LINE_CHAIN& poly = outline.Outline( 0 ); + cornerList.reserve( poly.PointCount() ); for( int ii = 0; ii < poly.PointCount(); ++ii ) cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y ); diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 6e1f3c954f..e82825509b 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -574,7 +574,8 @@ void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int aWidth, void * aData ) { - std::vector< wxPoint > cornerList; + std::vector cornerList; + cornerList.reserve( aCornerList.PointCount() ); for( int ii = 0; ii < aCornerList.PointCount(); ii++ ) cornerList.emplace_back( aCornerList.CPoint( ii ) ); @@ -582,7 +583,7 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, if( aCornerList.IsClosed() && cornerList.front() != cornerList.back() ) cornerList.emplace_back( aCornerList.CPoint( 0 ) ); - PlotPoly( cornerList , aFill, aWidth, aData ); + PlotPoly( cornerList, aFill, aWidth, aData ); } diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index 18be100693..64529eb83d 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -37,7 +37,7 @@ bool compareFileExtensions( const std::string& aExtension, // Form the regular expression string by placing all possible extensions into it as alternatives std::string regexString = "("; bool first = true; - for( auto ext : aReference ) + for( const auto& ext : aReference ) { // The | separate goes between the extensions if( !first ) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 1c2442d631..79d3d98ae6 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -398,7 +398,7 @@ void CVPCB_MAINFRAME::UndoAssociation() m_undoList.pop_back(); // Iterate over the entries to undo - for( auto assoc : curEntry ) + for( const auto& assoc : curEntry ) { AssociateFootprint( assoc, true, false ); redoEntries.emplace_back( assoc.Reverse() ); @@ -419,7 +419,7 @@ void CVPCB_MAINFRAME::RedoAssociation() // Iterate over the entries to undo bool firstAssoc = true; - for( auto assoc : curEntry ) + for( const auto& assoc : curEntry ) { AssociateFootprint( assoc, firstAssoc ); firstAssoc = false; diff --git a/eeschema/dialogs/dialog_bus_manager.cpp b/eeschema/dialogs/dialog_bus_manager.cpp index 608b34178d..c02faf28c5 100644 --- a/eeschema/dialogs/dialog_bus_manager.cpp +++ b/eeschema/dialogs/dialog_bus_manager.cpp @@ -209,7 +209,7 @@ bool DIALOG_BUS_MANAGER::TransferDataToWindow() // clone into a temporary working set int idx = 0; - for( auto alias : original_aliases ) + for( const auto& alias : original_aliases ) { m_aliases.push_back( alias->Clone() ); auto text = getAliasDisplayText( alias ); @@ -249,7 +249,7 @@ bool DIALOG_BUS_MANAGER::TransferDataFromWindow() std::unordered_set< SCH_SCREEN* > cleared_list; - for( auto alias : m_aliases ) + for( const auto& alias : m_aliases ) { auto screen = alias->GetParent(); @@ -348,7 +348,7 @@ void DIALOG_BUS_MANAGER::OnAddBus( wxCommandEvent& aEvent ) return; } - for( auto alias : m_aliases ) + for( const auto& alias : m_aliases ) { if( alias->GetName() == new_name ) { diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 1d7a2b954d..b832569079 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -148,7 +148,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() } // Add in any template fieldnames not yet defined: - for( TEMPLATE_FIELDNAME templateFieldname : GetParent()->GetTemplateFieldNames() ) + for( const TEMPLATE_FIELDNAME& templateFieldname : GetParent()->GetTemplateFieldNames() ) { if( defined.count( templateFieldname.m_Name ) <= 0 ) { @@ -456,7 +456,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() { SCH_FIELD& field = m_fields->at( i ); - for( auto fieldname : templateFieldnames ) + for( const auto& fieldname : templateFieldnames ) { if( field.GetName() == fieldname.m_Name && field.GetText().IsEmpty() ) { @@ -664,7 +664,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary( wxCommandEvent } // Add in any template fieldnames not yet defined: - for( TEMPLATE_FIELDNAME templateFieldname : GetParent()->GetTemplateFieldNames() ) + for( const TEMPLATE_FIELDNAME& templateFieldname : GetParent()->GetTemplateFieldNames() ) { if( defined.count( templateFieldname.m_Name ) <= 0 ) { diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 14a34c01e5..3891fe1d6c 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -204,7 +204,7 @@ bool DIALOG_LABEL_EDITOR::TransferDataToWindow() wxArrayString existingLabelArray; - for( wxString label : existingLabels ) + for( const wxString& label : existingLabels ) existingLabelArray.push_back( label ); // existingLabelArray.Sort(); diff --git a/eeschema/dialogs/dialog_sim_settings.cpp b/eeschema/dialogs/dialog_sim_settings.cpp index 7010807b90..0c602c1339 100644 --- a/eeschema/dialogs/dialog_sim_settings.cpp +++ b/eeschema/dialogs/dialog_sim_settings.cpp @@ -296,7 +296,7 @@ int DIALOG_SIM_SETTINGS::ShowModal() for( auto c : cmbNet ) c.first->Clear(); - for( auto net : m_exporter->GetNetIndexMap() ) + for( const auto& net : m_exporter->GetNetIndexMap() ) { for( auto c : cmbNet ) c.first->Append( net.first ); @@ -322,7 +322,7 @@ int DIALOG_SIM_SETTINGS::ShowModal() for( auto c : cmbSrc ) c.first->Clear(); - for( auto item : m_exporter->GetSpiceItems() ) + for( const auto& item : m_exporter->GetSpiceItems() ) { if( item.m_primitive == 'V' ) { diff --git a/eeschema/dialogs/dialog_spice_model.cpp b/eeschema/dialogs/dialog_spice_model.cpp index b03d8cb129..15d7dfb687 100644 --- a/eeschema/dialogs/dialog_spice_model.cpp +++ b/eeschema/dialogs/dialog_spice_model.cpp @@ -267,7 +267,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow() // Do not modify the existing value, just add missing fields with default values if( m_useSchFields && m_schfields ) { - for( auto field : *m_schfields ) + for( const auto& field : *m_schfields ) { if( field.GetName() == spiceField && !field.GetText().IsEmpty() ) { @@ -279,7 +279,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow() else if( m_libfields) { // TODO: There must be a good way to template out these repetitive calls - for( auto field : *m_libfields ) + for( const auto& field : *m_libfields ) { if( field.GetName() == spiceField && !field.GetText().IsEmpty() ) { diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 470814c31c..13fd5db5b9 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -642,7 +642,7 @@ void PANEL_SYM_LIB_TABLE::populateEnvironReadOnlyTable() unique.insert( PROJECT_VAR_NAME ); unique.insert( SYMBOL_LIB_TABLE::GlobalPathEnvVariableName() ); - for( wxString evName : unique ) + for( const wxString& evName : unique ) { int row = m_path_subs_grid->GetNumberRows(); m_path_subs_grid->AppendRows( 1 ); diff --git a/eeschema/libedit/lib_manager.cpp b/eeschema/libedit/lib_manager.cpp index e2322eabcd..c282db06cd 100644 --- a/eeschema/libedit/lib_manager.cpp +++ b/eeschema/libedit/lib_manager.cpp @@ -446,12 +446,12 @@ bool LIB_MANAGER::RevertAll() if( GetHash() == 0 ) return true; - for( auto lib : m_libs ) + for( const auto& lib : m_libs ) { if( !lib.second.IsModified() ) continue; - for( auto buffer : lib.second.GetBuffers() ) + for( const auto& buffer : lib.second.GetBuffers() ) { if( !buffer->IsModified() ) continue; diff --git a/eeschema/netlist_object.cpp b/eeschema/netlist_object.cpp index a38929ec62..f40c30499e 100644 --- a/eeschema/netlist_object.cpp +++ b/eeschema/netlist_object.cpp @@ -266,7 +266,7 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem std::list bus_contents( bus_contents_vec.begin(), bus_contents_vec.end() ); - for( auto bus_member : bus_contents ) + for( const auto& bus_member : bus_contents ) { // Nested bus vector inside a bus group if( conn.IsBusVectorLabel( bus_member ) ) @@ -295,7 +295,7 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem else if( auto nested_alias = SCH_SCREEN::GetBusAlias( bus_member ) ) { // Nested alias inside a group - for( auto alias_member : nested_alias->Members() ) + for( const auto& alias_member : nested_alias->Members() ) { bus_contents.push_back( alias_member ); } diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 5886e6e66c..7309aed5ad 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -89,7 +89,7 @@ void SCH_CONNECTION::SetDriver( SCH_ITEM* aItem ) { m_driver = aItem; - for( auto member : m_members ) + for( const auto& member : m_members ) member->SetDriver( aItem ); } @@ -98,7 +98,7 @@ void SCH_CONNECTION::SetSheet( SCH_SHEET_PATH aSheet ) { m_sheet = aSheet; - for( auto member : m_members ) + for( const auto& member : m_members ) member->SetSheet( aSheet ); } @@ -289,7 +289,7 @@ void SCH_CONNECTION::SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; - for( auto m : Members() ) + for( const auto& m : Members() ) m->SetPrefix( aPrefix ); } @@ -298,7 +298,7 @@ void SCH_CONNECTION::SetSuffix( const wxString& aSuffix ) { m_suffix = aSuffix; - for( auto m : Members() ) + for( const auto& m : Members() ) m->SetSuffix( aSuffix ); } @@ -325,14 +325,14 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const wxString members; - for( auto member : alias->Members() ) + for( const auto& member : alias->Members() ) members << member << " "; aList.push_back( MSG_PANEL_ITEM( msg, members, RED ) ); } else if( ParseBusGroup( m_name, &group_name, group_members ) ) { - for( auto group_member : group_members ) + for( const auto& group_member : group_members ) { if( auto group_alias = g_ConnectionGraph->GetBusAlias( group_member ) ) { @@ -340,7 +340,7 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const wxString members; - for( auto member : group_alias->Members() ) + for( const auto& member : group_alias->Members() ) members << member << " "; aList.push_back( MSG_PANEL_ITEM( msg, members, RED ) ); @@ -521,10 +521,10 @@ bool SCH_CONNECTION::IsSubsetOf( SCH_CONNECTION* aOther ) const std::vector mine, theirs; - for( auto m : Members() ) + for( const auto& m : Members() ) mine.push_back( m->Name( true ) ); - for( auto m : aOther->Members() ) + for( const auto& m : aOther->Members() ) theirs.push_back( m->Name( true ) ); std::set subset; @@ -544,7 +544,7 @@ bool SCH_CONNECTION::IsMemberOfBus( SCH_CONNECTION* aOther ) const auto me = Name( true ); - for( auto m : aOther->Members() ) + for( const auto& m : aOther->Members() ) if( m->Name( true ) == me ) return true; diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 494932074d..765feaa8c5 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -1167,7 +1167,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) component->GetField( REFERENCE )->SetVisible( part->GetField( REFERENCE )->IsVisible() ); component->GetField( VALUE )->SetVisible( part->GetField( VALUE )->IsVisible() ); - for( auto a:epart->attribute ) + for( const auto& a : epart->attribute ) { auto field = component->AddField( *component->GetField( VALUE ) ); field->SetName( a.first ); @@ -1175,7 +1175,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) field->SetVisible( false ); } - for( auto a:epart->variant ) + for( const auto& a : epart->variant ) { auto field = component->AddField( *component->GetField( VALUE ) ); field->SetName( "VARIANT_" + a.first ); @@ -1437,7 +1437,7 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrconnects.size() != 0 ) { - for( auto connect : aDevice->connects ) + for( const auto& connect : aDevice->connects ) { if( connect.gate == aGateName && pin->GetName() == connect.pin ) { diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 5c3a2b8900..116a66e1e6 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -1846,7 +1846,7 @@ void SCH_LEGACY_PLUGIN::Format( SCH_SCREEN* aScreen ) m_out->Print( 0, "Comment9 %s\n", EscapedUTF8( tb.GetComment( 8 ) ).c_str() ); m_out->Print( 0, "$EndDescr\n" ); - for( auto alias : aScreen->GetBusAliases() ) + for( const auto& alias : aScreen->GetBusAliases() ) { saveBusAlias( alias ); } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 0b3daf3c3f..d5911fa854 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -921,7 +921,7 @@ bool SCH_SCREEN::IsBusAlias( const wxString& aLabel ) SCH_SHEET_LIST aSheets( g_RootSheet ); for( unsigned i = 0; i < aSheets.size(); i++ ) { - for( auto alias : aSheets[i].LastScreen()->GetBusAliases() ) + for( const auto& alias : aSheets[i].LastScreen()->GetBusAliases() ) { if( alias->GetName() == aLabel ) { diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index a775f7b061..39a523746d 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -476,7 +476,7 @@ bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints, { bool hasVoltageTraces = false; - for( auto tr : m_traces ) + for( const auto& tr : m_traces ) { if( !( tr.second->GetFlags() & SPT_CURRENT ) ) { diff --git a/pcbnew/connectivity/connectivity_algo.h b/pcbnew/connectivity/connectivity_algo.h index 80c59603cc..ad5cc30b6f 100644 --- a/pcbnew/connectivity/connectivity_algo.h +++ b/pcbnew/connectivity/connectivity_algo.h @@ -199,7 +199,7 @@ public: void GetDirtyClusters( CLUSTERS& aClusters ) { - for( auto cl : m_ratsnestClusters ) + for( const auto& cl : m_ratsnestClusters ) { int net = cl->OriginNet(); diff --git a/pcbnew/connectivity/connectivity_data.cpp b/pcbnew/connectivity/connectivity_data.cpp index 90222cb5e4..11e6002526 100644 --- a/pcbnew/connectivity/connectivity_data.cpp +++ b/pcbnew/connectivity/connectivity_data.cpp @@ -175,7 +175,7 @@ void CONNECTIVITY_DATA::RecalculateRatsnest( BOARD_COMMIT* aCommit ) } } - for( auto c : clusters ) + for( const auto& c : clusters ) { int net = c->OriginNet(); @@ -208,13 +208,13 @@ void CONNECTIVITY_DATA::BlockRatsnestItems( const std::vector& aIte } } - for( auto item : citems ) + for( const auto& item : citems ) { if ( m_connAlgo->ItemExists( item ) ) { auto& entry = m_connAlgo->ItemEntry( item ); - for( auto cnItem : entry.GetItems() ) + for( const auto& cnItem : entry.GetItems() ) { for( auto anchor : cnItem->Anchors() ) anchor->SetNoLine( true ); @@ -592,7 +592,7 @@ void CONNECTIVITY_DATA::GetUnconnectedEdges( std::vector& aEdges) const { if( rnNet ) { - for( auto edge : rnNet->GetEdges() ) + for( const auto& edge : rnNet->GetEdges() ) { aEdges.push_back( edge ); } @@ -666,7 +666,7 @@ void CONNECTIVITY_DATA::SetProgressReporter( PROGRESS_REPORTER* aReporter ) const std::vector CONNECTIVITY_DATA::GetRatsnestForComponent( MODULE* aComponent, bool aSkipInternalConnections ) { std::set nets; - std::set pads; + std::set pads; std::vector edges; for( auto pad : aComponent->Pads() ) @@ -675,17 +675,17 @@ const std::vector CONNECTIVITY_DATA::GetRatsnestForComponent( MODULE* a pads.insert( pad ); } - for ( auto netcode : nets ) + for( const auto& netcode : nets ) { - auto net = GetRatsnestForNet( netcode ); + const auto& net = GetRatsnestForNet( netcode ); - for ( auto edge : net->GetEdges() ) + for( const auto& edge : net->GetEdges() ) { auto srcNode = edge.GetSourceNode(); auto dstNode = edge.GetTargetNode(); - auto srcParent = static_cast( srcNode->Parent() ); - auto dstParent = static_cast( dstNode->Parent() ); + auto srcParent = static_cast( srcNode->Parent() ); + auto dstParent = static_cast( dstNode->Parent() ); bool srcFound = ( pads.find(srcParent) != pads.end() ); bool dstFound = ( pads.find(dstParent) != pads.end() ); diff --git a/pcbnew/dialogs/dialog_board_statistics.cpp b/pcbnew/dialogs/dialog_board_statistics.cpp index 25d65eedb3..2e4b044278 100644 --- a/pcbnew/dialogs/dialog_board_statistics.cpp +++ b/pcbnew/dialogs/dialog_board_statistics.cpp @@ -691,13 +691,14 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent ) std::vector labels{ "", _( "Front Side" ), _( "Back Side" ), _( "Total" ) }; wxString tmp; - for( auto label : labels ) + widths.reserve( labels.size() ); + for( const auto& label : labels ) widths.push_back( label.size() ); int frontTotal = 0; int backTotal = 0; - for( auto type : m_componentsTypes ) + for( const auto& type : m_componentsTypes ) { // Get maximum width for left label column widths[0] = std::max( type.title.size(), widths[0] ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index b22810821c..e90b4bf1f4 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -357,7 +357,7 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow() wxString origPath, alias, shortPath; FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); - for( MODULE_3D_SETTINGS model : m_footprint->Models() ) + for( const MODULE_3D_SETTINGS& model : m_footprint->Models() ) { m_shapes3D_list.push_back( model ); origPath = model.m_Filename; diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 45e2918a5e..a7d11b813c 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -285,7 +285,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow() wxString origPath, alias, shortPath; FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); - for( MODULE_3D_SETTINGS model : m_footprint->Models() ) + for( const MODULE_3D_SETTINGS& model : m_footprint->Models() ) { m_shapes3D_list.push_back( model ); origPath = model.m_Filename; diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index c062e6d15e..182bf84683 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -779,7 +779,7 @@ void PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable() // This special environment variable is used to locate 3d shapes unique.insert( KISYS3DMOD ); - for( wxString evName : unique ) + for( const wxString& evName : unique ) { int row = m_path_subs_grid->GetNumberRows(); m_path_subs_grid->AppendRows( 1 ); diff --git a/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp b/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp index c003909ab5..01d28bacca 100644 --- a/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp +++ b/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp @@ -138,6 +138,7 @@ bool PANEL_PCBNEW_ACTION_PLUGINS::TransferDataFromWindow() { std::vector< std::pair > pluginSettings; + pluginSettings.reserve( m_grid->GetNumberRows() ); for( int ii = 0; ii < m_grid->GetNumberRows(); ii++ ) { pluginSettings.emplace_back( diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index e37376728d..89765fb4f8 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1117,6 +1117,7 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P // TransformRoundChamferedRectToPolygon creates only one convex polygon SHAPE_LINE_CHAIN poly( polySet.Outline( 0 ) ); + cornerList.reserve( poly.PointCount() ); for( int ii = 0; ii < poly.PointCount(); ++ii ) cornerList.emplace_back( poly.Point( ii ).x * BOARD_SCALE, -poly.Point( ii ).y * BOARD_SCALE ); diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index 4b37dbd40c..14eb7e4e8c 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -844,7 +844,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) if( m_isDryRun ) { - for( auto it : m_addedNets ) + for( const auto& it : m_addedNets ) delete it.second; m_addedNets.clear(); diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index 250747d692..b4be788ffa 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -230,12 +230,12 @@ public: CN_ANCHOR_PTR prev, last; int id = 0; - for( auto n : m_allNodes ) + for( const auto& n : m_allNodes ) { anchorChains.emplace_back( ); } - for( auto n : m_allNodes ) + for( const auto& n : m_allNodes ) { if( !prev || prev->Pos() != n->Pos() ) { @@ -251,7 +251,7 @@ public: int prevId = 0; - for( auto n : triNodes ) + for( const auto& n : triNodes ) { for( int i = prevId; i < n->Id(); i++ ) anchorChains[prevId].push_back( m_allNodes[ i ] ); @@ -284,7 +284,7 @@ public: triangulator.CreateDelaunay( triNodes.begin(), triNodes.end() ); triangulator.GetEdges( triangEdges ); - for( auto e : triangEdges ) + for( const auto& e : triangEdges ) { auto src = m_allNodes[ e->GetSourceNode()->Id() ]; auto dst = m_allNodes[ e->GetTargetNode()->Id() ]; @@ -348,7 +348,7 @@ void RN_NET::compute() else { // Set tags to m_nodes as connected - for( auto node : m_nodes ) + for( const auto& node : m_nodes ) node->SetTag( 0 ); } @@ -358,7 +358,7 @@ void RN_NET::compute() m_triangulator->Clear(); - for( auto n : m_nodes ) + for( const auto& n : m_nodes ) { m_triangulator->AddNode( n ); } @@ -445,9 +445,9 @@ bool RN_NET::NearestBicoloredPair( const RN_NET& aOtherNet, CN_ANCHOR_PTR& aNode VECTOR2I::extended_type distMax = VECTOR2I::ECOORD_MAX; - for( auto nodeA : m_nodes ) + for( const auto& nodeA : m_nodes ) { - for( auto nodeB : aOtherNet.m_nodes ) + for( const auto& nodeB : aOtherNet.m_nodes ) { if( !nodeA->GetNoLine() ) { diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 9e2a1fd057..0404a90417 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -130,7 +130,7 @@ bool LINE_PLACER::handleSelfIntersections() // if there is more than one intersection, find the one that is // closest to the beginning of the tail. - for( SHAPE_LINE_CHAIN::INTERSECTION i : ips ) + for( const SHAPE_LINE_CHAIN::INTERSECTION& i : ips ) { if( i.our.Index() < n ) { diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index ee772e40a7..4f7ad13135 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -347,7 +347,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask, viaHull.Intersect( hull, isect_list ); - for( SHAPE_LINE_CHAIN::INTERSECTION isect : isect_list ) + for( const SHAPE_LINE_CHAIN::INTERSECTION& isect : isect_list ) { int dist = aLine.CLine().Length() + ( isect.p - aLine.Via().Pos() ).EuclideanNorm(); @@ -373,7 +373,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask, hull.Intersect( aLine.CLine(), isect_list ); - for( SHAPE_LINE_CHAIN::INTERSECTION isect : isect_list ) + for( const SHAPE_LINE_CHAIN::INTERSECTION& isect : isect_list ) { int dist = aLine.CLine().PathLength( isect.p ); diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 367f368968..d98a6825d5 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -364,7 +364,7 @@ void TOOL_BASE::deleteTraces( ITEM* aStartItem, bool aWholeTrack ) TOPOLOGY topo( node ); ITEM_SET path = topo.AssembleTrivialPath( aStartItem ); - for( auto ent : path.Items() ) + for( const auto& ent : path.Items() ) node->Remove( ent.item ); } diff --git a/pcbnew/router/pns_topology.cpp b/pcbnew/router/pns_topology.cpp index 0612835276..e671aca79c 100644 --- a/pcbnew/router/pns_topology.cpp +++ b/pcbnew/router/pns_topology.cpp @@ -251,7 +251,7 @@ const ITEM_SET TOPOLOGY::AssembleTrivialPath( ITEM* aStart ) if( !jt->IsNonFanoutVia() ) return ITEM_SET(); - for( auto entry : jt->Links().Items() ) + for( const auto& entry : jt->Links().Items() ) if( ( seg = dyn_cast( entry.item ) ) ) break; } diff --git a/utils/idftools/dxf2idfmain.cpp b/utils/idftools/dxf2idfmain.cpp index df804c15be..24bb9053ad 100644 --- a/utils/idftools/dxf2idfmain.cpp +++ b/utils/idftools/dxf2idfmain.cpp @@ -89,7 +89,7 @@ int main( int argc, char **argv ) line.clear(); std::getline( cin, line ); - if( line.find( "\"" ) != string::npos ) + if( line.find( '\"' ) != string::npos ) { cerr << "[INFO] geometry name may not contain quotation marks\n"; line.clear(); @@ -104,7 +104,7 @@ int main( int argc, char **argv ) line.clear(); std::getline( cin, line ); - if( line.find( "\"" ) != string::npos ) + if( line.find( '\"' ) != string::npos ) { cerr << "[INFO] part name may not contain quotation marks\n"; line.clear(); diff --git a/utils/kicad2step/pcb/3d_resolver.cpp b/utils/kicad2step/pcb/3d_resolver.cpp index d3468514ab..ca87c094cf 100644 --- a/utils/kicad2step/pcb/3d_resolver.cpp +++ b/utils/kicad2step/pcb/3d_resolver.cpp @@ -862,7 +862,7 @@ wxString S3D_RESOLVER::expandVars( const wxString& aPath ) wxString result; - for( auto i: m_EnvVars ) + for( const auto& i : m_EnvVars ) { if( !aPath.compare( 2, i.first.length(), i.first ) ) { diff --git a/utils/kicad2step/pcb/oce_utils.cpp b/utils/kicad2step/pcb/oce_utils.cpp index 07f3367722..d23edca779 100644 --- a/utils/kicad2step/pcb/oce_utils.cpp +++ b/utils/kicad2step/pcb/oce_utils.cpp @@ -806,7 +806,7 @@ bool PCBMODEL::CreatePCB() } // subtract cutouts (if any) - for( auto i : m_cutouts ) + for( const auto& i : m_cutouts ) board = BRepAlgoAPI_Cut( board, i ); // push the board to the data structure @@ -995,7 +995,7 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TRIPLET aScale, TDF_L //TODO - Other alternative formats? - for( auto alt : alts ) + for( const auto& alt : alts ) { wxFileName altFile( basePath, baseName + "." + alt );