← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Fix some performance issues

 

Hi,


Here is a new/final version of my patchset.


Best regards

--
Camille

________________________________
De : Kicad-developers <kicad-developers-bounces+camille019=outlook.com@xxxxxxxxxxxxxxxxxxx> de la part de Camille 019 <camille019@xxxxxxxxxxx>
Envoyé : samedi 23 septembre 2017 12:17
À : kicad-developers@xxxxxxxxxxxxxxxxxxx
Objet : [Kicad-developers] [PATCH] Fix some performance issues


Hi all,


I recently play with clang-tidy on the KiCad source code. Here is a set of 2 patch which fix the unnecessary-copy-initialization<https://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-copy-initialization.html> and unnecessary-value-param<https://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-value-param.html> checks.


I will run more performance checks in the future. The next two:

- for-range-copy<https://clang.llvm.org/extra/clang-tidy/checks/performance-for-range-copy.html>

- type-promotion-in-math-fn<https://clang.llvm.org/extra/clang-tidy/checks/performance-type-promotion-in-math-fn.html>


Best regards,


--

Camille
From 89b25bb2a8bd1150470c42dac1d43be4447233a9 Mon Sep 17 00:00:00 2001
From: Camille <camille019@xxxxxxxxxxx>
Date: Sun, 24 Sep 2017 20:11:58 +0200
Subject: [PATCH 4/4] Fix loop variable copy in for-range loop, use const
 reference instead
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.13.5"

This is a multi-part message in MIME format.
--------------2.13.5
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 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/dialogs/dialog_bom_editor.cpp                 |  2 +-
 eeschema/netlist_exporters/netlist_exporter_pspice.cpp |  2 +-
 eeschema/sch_sheet.cpp                                 |  6 +++---
 kicad/prjconfig.cpp                                    |  4 ++--
 kicad/project_template.cpp                             |  4 ++--
 pcbnew/clean.cpp                                       |  2 +-
 pcbnew/connectivity_algo.cpp                           | 12 ++++++------
 pcbnew/router/pns_diff_pair.cpp                        |  2 +-
 12 files changed, 22 insertions(+), 22 deletions(-)


--------------2.13.5
Content-Type: text/x-patch; name="0004-Fix-loop-variable-copy-in-for-range-loop-use-const-r.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0004-Fix-loop-variable-copy-in-for-range-loop-use-const-r.patch"

diff --git a/3d-viewer/3d_cache/3d_filename_resolver.cpp b/3d-viewer/3d_cache/3d_filename_resolver.cpp
index 2e6000170..82ff7dfc7 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 ceb85e9b4..19c9ed9c3 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 244abfc4c..0195fe81b 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 );
     }
@@ -260,7 +260,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 044feffb6..6bc276306 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/dialogs/dialog_bom_editor.cpp b/eeschema/dialogs/dialog_bom_editor.cpp
index f314dd6fc..47b7a687f 100644
--- a/eeschema/dialogs/dialog_bom_editor.cpp
+++ b/eeschema/dialogs/dialog_bom_editor.cpp
@@ -209,7 +209,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/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp
index 66af766ce..f69c33429 100644
--- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp
+++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp
@@ -68,7 +68,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 9a975d2b2..27689f778 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -389,7 +389,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;
@@ -401,7 +401,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;
@@ -412,7 +412,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/kicad/prjconfig.cpp b/kicad/prjconfig.cpp
index f1cb7d57a..dbc481fa7 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 a791b5657..495051074 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 85eba519a..74e552ecd 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 e2df159ca..7c71321d4 100644
--- a/pcbnew/connectivity_algo.cpp
+++ b/pcbnew/connectivity_algo.cpp
@@ -746,7 +746,7 @@ void CN_CONNECTIVITY_ALGO::Build( const std::vector<BOARD_ITEM*>& aItems )
 
 void CN_CONNECTIVITY_ALGO::propagateConnections()
 {
-    for( auto cluster : m_connClusters )
+    for( const auto& cluster : m_connClusters )
     {
         if( cluster->IsConflicting() )
         {
@@ -811,7 +811,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() )
         {
@@ -966,16 +966,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 )
 {
-    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 26b4d301a..94854b08c 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 ) );

--------------2.13.5--


From c055f2b0fec9f18521b4168c01d695f045179226 Mon Sep 17 00:00:00 2001
From: Camille <camille019@xxxxxxxxxxx>
Date: Sat, 23 Sep 2017 11:20:10 +0200
Subject: [PATCH 2/4] Fix unnecessary value parameter detected by clang-tidy. 
 - Replace value parameter by const reference parameter    or move-assignement
 in some cases
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.13.5"

This is a multi-part message in MIME format.
--------------2.13.5
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 3d-viewer/3d_rendering/buffers_debug.cpp          | 10 ++--
 3d-viewer/3d_rendering/buffers_debug.h            |  8 +--
 3d-viewer/3d_rendering/cimage.cpp                 |  2 +-
 3d-viewer/3d_rendering/cimage.h                   |  2 +-
 common/confirm.cpp                                |  5 +-
 common/eagle_parser.cpp                           |  4 +-
 common/footprint_info.cpp                         |  3 +-
 common/gal/gal_display_options.cpp                |  4 +-
 common/gal/opengl/opengl_gal.cpp                  |  2 +-
 common/geometry/shape_file_io.cpp                 |  4 +-
 common/geometry/shape_poly_set.cpp                |  2 +-
 common/incremental_text_ctrl.cpp                  |  4 +-
 common/search_stack.cpp                           |  2 +-
 common/tool/tool_action.cpp                       |  2 +-
 common/widgets/mathplot.cpp                       | 20 +++----
 eeschema/bom_table_column.cpp                     |  4 +-
 eeschema/bom_table_column.h                       |  4 +-
 eeschema/bom_table_model.cpp                      |  6 +--
 eeschema/bom_table_model.h                        |  6 +--
 eeschema/cmp_tree_model_adapter.cpp               |  2 +-
 eeschema/cmp_tree_model_adapter.h                 |  2 +-
 eeschema/dialogs/dialog_annotate.cpp              |  6 +--
 eeschema/invoke_sch_dialog.h                      |  2 +-
 eeschema/project_rescue.cpp                       |  2 +-
 eeschema/sch_component.cpp                        |  2 +-
 eeschema/sch_component.h                          |  2 +-
 eeschema/sch_field.cpp                            |  2 +-
 eeschema/sch_field.h                              |  2 +-
 eeschema/sch_sheet_path.cpp                       |  2 +-
 eeschema/sch_sheet_path.h                         |  2 +-
 include/class_board_item.h                        |  2 +-
 include/confirm.h                                 |  4 +-
 include/gal/gal_display_options.h                 |  4 +-
 include/gal/opengl/opengl_gal.h                   |  2 +-
 include/geometry/shape_file_io.h                  |  4 +-
 include/geometry/shape_poly_set.h                 |  2 +-
 include/search_stack.h                            |  2 +-
 include/tool/tool_action.h                        |  2 +-
 include/widgets/mathplot.h                        | 20 +++----
 kicad/commandframe.cpp                            |  2 +-
 kicad/kicad.h                                     |  2 +-
 lib_dxf/drw_objects.cpp                           | 21 ++++----
 lib_dxf/drw_objects.h                             | 18 +++----
 lib_dxf/intern/drw_textcodec.cpp                  |  2 +-
 lib_dxf/intern/drw_textcodec.h                    |  2 +-
 lib_dxf/intern/dxfwriter.cpp                      |  5 +-
 lib_dxf/libdxfrw.cpp                              |  4 +-
 lib_dxf/libdxfrw.h                                |  4 +-
 pcb_calculator/datafile_read_write.cpp            |  2 +-
 pcb_calculator/datafile_read_write.h              |  2 +-
 pcbnew/class_action_plugin.cpp                    |  2 +-
 pcbnew/class_action_plugin.h                      |  2 +-
 pcbnew/class_board_item.cpp                       |  2 +-
 pcbnew/class_footprint_wizard.cpp                 |  2 +-
 pcbnew/class_footprint_wizard.h                   |  2 +-
 pcbnew/class_module.cpp                           |  2 +-
 pcbnew/class_module.h                             |  2 +-
 pcbnew/class_netclass.cpp                         |  2 +-
 pcbnew/class_netclass.h                           |  2 +-
 pcbnew/class_netinfo.h                            |  2 +-
 pcbnew/class_netinfo_item.cpp                     |  2 +-
 pcbnew/clean.cpp                                  |  2 +-
 pcbnew/connectivity.cpp                           | 12 ++---
 pcbnew/connectivity.h                             |  2 +-
 pcbnew/connectivity_algo.cpp                      | 22 ++++----
 pcbnew/connectivity_algo.h                        |  6 +--
 pcbnew/dialogs/dialog_create_array.cpp            |  2 +-
 pcbnew/dialogs/dialog_design_rules.cpp            |  4 +-
 pcbnew/drc.cpp                                    |  2 +-
 pcbnew/drc_stuff.h                                |  2 +-
 pcbnew/footprint_info_impl.cpp                    |  2 +-
 pcbnew/footprint_info_impl.h                      |  2 +-
 pcbnew/footprint_preview_panel.cpp                |  3 +-
 pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp | 66 +++++++++++------------
 pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h   | 58 ++++++++++----------
 pcbnew/pcad2kicadpcb_plugin/pcb.cpp               | 19 ++++---
 pcbnew/pcad2kicadpcb_plugin/pcb.h                 | 37 +++++++------
 pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp           |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_arc.h             |  6 ++-
 pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp   |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.h     |  4 +-
 pcbnew/pcad2kicadpcb_plugin/pcb_cutout.cpp        |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_cutout.h          |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_keepout.cpp       |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_keepout.h         |  4 +-
 pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp          |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_line.h            |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp        | 11 ++--
 pcbnew/pcad2kicadpcb_plugin/pcb_module.h          | 11 ++--
 pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp           |  5 +-
 pcbnew/pcad2kicadpcb_plugin/pcb_pad.h             |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.cpp     |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.h       |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_plane.cpp         |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_plane.h           |  4 +-
 pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp       | 13 ++---
 pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h         |  9 ++--
 pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp          |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_text.h            |  8 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_via.cpp           |  5 +-
 pcbnew/pcad2kicadpcb_plugin/pcb_via.h             |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.cpp     |  6 +--
 pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.h       |  6 +--
 pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp     |  5 +-
 pcbnew/pcad2kicadpcb_plugin/s_expr_loader.h       |  5 +-
 pcbnew/ratsnest_viewitem.cpp                      |  3 +-
 pcbnew/router/pns_diff_pair.cpp                   |  4 +-
 pcbnew/router/pns_diff_pair.h                     |  4 +-
 pcbnew/router/pns_kicad_iface.cpp                 |  4 +-
 pcbnew/router/pns_logger.cpp                      |  6 +--
 pcbnew/router/pns_logger.h                        |  6 +--
 pcbnew/specctra.cpp                               |  4 +-
 pcbnew/specctra.h                                 |  6 +--
 pcbnew/specctra_export.cpp                        |  2 +-
 pcbnew/tools/edit_constraints.cpp                 |  4 +-
 pcbnew/tools/pad_tool.cpp                         |  4 +-
 polygon/poly2tri/sweep/cdt.cc                     |  6 ++-
 polygon/poly2tri/sweep/sweep_context.cc           |  3 +-
 utils/idftools/dxf2idf.cpp                        |  2 +-
 utils/idftools/dxf2idf.h                          |  2 +-
 utils/idftools/idf_common.cpp                     |  4 +-
 utils/idftools/idf_common.h                       |  4 +-
 utils/idftools/idf_outlines.cpp                   |  5 +-
 utils/idftools/idf_outlines.h                     |  2 +-
 utils/idftools/idf_parser.cpp                     | 19 +++----
 utils/idftools/idf_parser.h                       | 16 +++---
 126 files changed, 413 insertions(+), 378 deletions(-)


--------------2.13.5
Content-Type: text/x-patch; name="0002-Fix-unnecessary-value-parameter-detected-by-clang-ti.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0002-Fix-unnecessary-value-parameter-detected-by-clang-ti.patch"

diff --git a/3d-viewer/3d_rendering/buffers_debug.cpp b/3d-viewer/3d_rendering/buffers_debug.cpp
index b5132cef5..3318900a1 100644
--- a/3d-viewer/3d_rendering/buffers_debug.cpp
+++ b/3d-viewer/3d_rendering/buffers_debug.cpp
@@ -39,7 +39,7 @@
  * @param aXSize
  * @param aYSize
  */
-static void dbg_save_rgb_buffer( wxString aFileName,
+static void dbg_save_rgb_buffer( const wxString& aFileName,
                                  unsigned char *aRGBpixelBuffer,
                                  unsigned int aXSize,
                                  unsigned int aYSize )
@@ -52,7 +52,7 @@ static void dbg_save_rgb_buffer( wxString aFileName,
 }
 
 
-void DBG_SaveBuffer( wxString aFileName,
+void DBG_SaveBuffer( const wxString& aFileName,
                      const unsigned char *aInBuffer,
                      unsigned int aXSize,
                      unsigned int aYSize )
@@ -75,7 +75,7 @@ void DBG_SaveBuffer( wxString aFileName,
 }
 
 
-void DBG_SaveBuffer( wxString aFileName,
+void DBG_SaveBuffer( const wxString& aFileName,
                      const float *aInBuffer,
                      unsigned int aXSize,
                      unsigned int aYSize )
@@ -99,7 +99,7 @@ void DBG_SaveBuffer( wxString aFileName,
 }
 
 
-void DBG_SaveBuffer( wxString aFileName,
+void DBG_SaveBuffer( const wxString& aFileName,
                      const SFVEC3F *aInBuffer,
                      unsigned int aXSize,
                      unsigned int aYSize )
@@ -123,7 +123,7 @@ void DBG_SaveBuffer( wxString aFileName,
 }
 
 
-void DBG_SaveNormalsBuffer( wxString aFileName,
+void DBG_SaveNormalsBuffer( const wxString& aFileName,
                             const SFVEC3F *aInNormalsBuffer,
                             unsigned int aXSize,
                             unsigned int aYSize )
diff --git a/3d-viewer/3d_rendering/buffers_debug.h b/3d-viewer/3d_rendering/buffers_debug.h
index bb6b38597..c64975d7a 100644
--- a/3d-viewer/3d_rendering/buffers_debug.h
+++ b/3d-viewer/3d_rendering/buffers_debug.h
@@ -33,21 +33,21 @@
 #include <plugins/3dapi/xv3d_types.h>
 #include <wx/string.h>
 
-void DBG_SaveBuffer( wxString aFileName,
+void DBG_SaveBuffer( const wxString& aFileName,
                      const unsigned char *aInBuffer,
                      unsigned int aXSize, unsigned int aYSize );
 
-void DBG_SaveBuffer( wxString aFileName,
+void DBG_SaveBuffer( const wxString& aFileName,
                      const float *aInBuffer,
                      unsigned int aXSize,
                      unsigned int aYSize );
 
-void DBG_SaveBuffer( wxString aFileName,
+void DBG_SaveBuffer( const wxString& aFileName,
                      const SFVEC3F *aInBuffer,
                      unsigned int aXSize,
                      unsigned int aYSize );
 
-void DBG_SaveNormalsBuffer( wxString aFileName,
+void DBG_SaveNormalsBuffer( const wxString& aFileName,
                             const SFVEC3F *aInNormalsBuffer,
                             unsigned int aXSize,
                             unsigned int aYSize );
diff --git a/3d-viewer/3d_rendering/cimage.cpp b/3d-viewer/3d_rendering/cimage.cpp
index 755ef0b88..78622970b 100644
--- a/3d-viewer/3d_rendering/cimage.cpp
+++ b/3d-viewer/3d_rendering/cimage.cpp
@@ -512,7 +512,7 @@ void CIMAGE::SetPixelsFromNormalizedFloat( const float * aNormalizedFloatArray )
 }
 
 
-void CIMAGE::SaveAsPNG( wxString aFileName ) const
+void CIMAGE::SaveAsPNG( const wxString& aFileName ) const
 {
     DBG_SaveBuffer( aFileName, m_pixels, m_width, m_height );
 }
diff --git a/3d-viewer/3d_rendering/cimage.h b/3d-viewer/3d_rendering/cimage.h
index 341dc54d3..1cf079268 100644
--- a/3d-viewer/3d_rendering/cimage.h
+++ b/3d-viewer/3d_rendering/cimage.h
@@ -186,7 +186,7 @@ public:
      * each of RGB channel will have the 8bit-channel from the image.
      * @param aFileName fime name (without extension)
      */
-    void SaveAsPNG( wxString aFileName ) const;
+    void SaveAsPNG( const wxString& aFileName ) const;
 
     /**
      * Function SetPixelsFromNormalizedFloat
diff --git a/common/confirm.cpp b/common/confirm.cpp
index 9c3ab3dfe..4e31ea05b 100644
--- a/common/confirm.cpp
+++ b/common/confirm.cpp
@@ -30,6 +30,7 @@
 #include <wx/stockitem.h>
 #include <wx/richmsgdlg.h>
 
+#include <confirm.h>
 #include <bitmaps.h>
 #include <html_messagebox.h>
 #include <dialog_exit_base.h>
@@ -82,7 +83,7 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
 }
 
 
-void DisplayErrorMessage( wxWindow* aParent, const wxString& aText, const wxString aExtraInfo )
+void DisplayErrorMessage( wxWindow* aParent, const wxString& aText, const wxString& aExtraInfo )
 {
     wxRichMessageDialog* dlg;
 
@@ -99,7 +100,7 @@ void DisplayErrorMessage( wxWindow* aParent, const wxString& aText, const wxStri
 }
 
 
-void DisplayInfoMessage( wxWindow* aParent, const wxString& aMessage, const wxString aExtraInfo )
+void DisplayInfoMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo )
 {
     wxRichMessageDialog* dlg;
 
diff --git a/common/eagle_parser.cpp b/common/eagle_parser.cpp
index e63b30bea..968d033e5 100644
--- a/common/eagle_parser.cpp
+++ b/common/eagle_parser.cpp
@@ -111,7 +111,7 @@ EROT Convert<EROT>( const wxString& aRot )
  * @return T - the attributed parsed as the specified type.
  */
 template<typename T>
-T parseRequiredAttribute( wxXmlNode* aNode, string aAttribute )
+T parseRequiredAttribute( wxXmlNode* aNode, const string& aAttribute )
 {
     wxString value;
 
@@ -130,7 +130,7 @@ T parseRequiredAttribute( wxXmlNode* aNode, string aAttribute )
  *                                   found.
  */
 template<typename T>
-OPTIONAL_XML_ATTRIBUTE<T> parseOptionalAttribute( wxXmlNode* aNode, string aAttribute )
+OPTIONAL_XML_ATTRIBUTE<T> parseOptionalAttribute( wxXmlNode* aNode, const string& aAttribute )
 {
     return OPTIONAL_XML_ATTRIBUTE<T>( aNode->GetAttribute( aAttribute ) );
 }
diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp
index ce31cf5e1..3f84e8b27 100644
--- a/common/footprint_info.cpp
+++ b/common/footprint_info.cpp
@@ -47,6 +47,7 @@
 #include <macros.h>
 #include <pgm_base.h>
 #include <thread>
+#include <utility>
 #include <wildcards_and_files_ext.h>
 
 
@@ -203,7 +204,7 @@ int FOOTPRINT_ASYNC_LOADER::GetProgress() const
 
 void FOOTPRINT_ASYNC_LOADER::SetCompletionCallback( std::function<void()> aCallback )
 {
-    m_completion_cb = aCallback;
+    m_completion_cb = std::move(aCallback);
 }
 
 
diff --git a/common/gal/gal_display_options.cpp b/common/gal/gal_display_options.cpp
index 92d46dedf..e3ef839f7 100644
--- a/common/gal/gal_display_options.cpp
+++ b/common/gal/gal_display_options.cpp
@@ -69,7 +69,7 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
 {}
 
 
-void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName )
+void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, const wxString& aBaseName )
 {
     long readLong; // Temp value buffer
 
@@ -100,7 +100,7 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName )
 }
 
 
-void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase* aCfg, wxString aBaseName )
+void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase* aCfg, const wxString& aBaseName )
 {
     aCfg->Write( aBaseName + GalGLAntialiasingKeyword,
                  UTIL::GetConfigForVal( aaModeConfigVals, gl_antialiasing_mode ) );
diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp
index ad485bb57..ee4db32b2 100644
--- a/common/gal/opengl/opengl_gal.cpp
+++ b/common/gal/opengl/opengl_gal.cpp
@@ -1501,7 +1501,7 @@ void OPENGL_GAL::drawPolygon( GLdouble* aPoints, int aPointCount )
 }
 
 
-void OPENGL_GAL::drawPolyline( std::function<VECTOR2D (int)> aPointGetter, int aPointCount )
+void OPENGL_GAL::drawPolyline( const std::function<VECTOR2D (int)>& aPointGetter, int aPointCount )
 {
     if( aPointCount < 2 )
         return;
diff --git a/common/geometry/shape_file_io.cpp b/common/geometry/shape_file_io.cpp
index a87fd744f..0c9a16689 100644
--- a/common/geometry/shape_file_io.cpp
+++ b/common/geometry/shape_file_io.cpp
@@ -105,7 +105,7 @@ SHAPE* SHAPE_FILE_IO::Read()
 }
 
 
-void SHAPE_FILE_IO::BeginGroup( const std::string aName )
+void SHAPE_FILE_IO::BeginGroup( const std::string& aName )
 {
     assert( m_mode != IOM_READ );
 
@@ -129,7 +129,7 @@ void SHAPE_FILE_IO::EndGroup()
 }
 
 
-void SHAPE_FILE_IO::Write( const SHAPE* aShape, const std::string aName )
+void SHAPE_FILE_IO::Write( const SHAPE* aShape, const std::string& aName )
 {
     assert( m_mode != IOM_READ );
 
diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp
index 63ed4ee4b..41e169428 100644
--- a/common/geometry/shape_poly_set.cpp
+++ b/common/geometry/shape_poly_set.cpp
@@ -1446,7 +1446,7 @@ int SHAPE_POLY_SET::Distance( VECTOR2I aPoint )
 }
 
 
-int SHAPE_POLY_SET::Distance( SEG aSegment, int aSegmentWidth )
+int SHAPE_POLY_SET::Distance( const SEG& aSegment, int aSegmentWidth )
 {
     int currentDistance;
     int minDistance = DistanceToPolygon( aSegment, 0 );
diff --git a/common/incremental_text_ctrl.cpp b/common/incremental_text_ctrl.cpp
index cc814c797..2fac82928 100644
--- a/common/incremental_text_ctrl.cpp
+++ b/common/incremental_text_ctrl.cpp
@@ -24,6 +24,8 @@
 
 #include <incremental_text_ctrl.h>
 
+#include <utility>
+
 /**
  * Check that a string looks like a floating point number that can
  * be dealt with.
@@ -61,7 +63,7 @@ void INCREMENTAL_TEXT_CTRL::SetStep( double aMin, double aMax,
 
     m_minVal = std::min( aMin, aMax );
     m_maxVal = std::max( aMin, aMax );
-    m_stepFunc = aStepFunc;
+    m_stepFunc = std::move(aStepFunc);
 
     // finally, clamp the current value and re-display
     updateTextValue();
diff --git a/common/search_stack.cpp b/common/search_stack.cpp
index 9982f4147..6c96c3fa5 100644
--- a/common/search_stack.cpp
+++ b/common/search_stack.cpp
@@ -34,7 +34,7 @@
 #endif
 
 
-int SEARCH_STACK::Split( wxArrayString* aResult, const wxString aPathString )
+int SEARCH_STACK::Split( wxArrayString* aResult, const wxString& aPathString )
 {
     wxStringTokenizer   tokenizer( aPathString, PATH_SEPS, wxTOKEN_STRTOK );
 
diff --git a/common/tool/tool_action.cpp b/common/tool/tool_action.cpp
index c73445f95..5a1cde498 100644
--- a/common/tool/tool_action.cpp
+++ b/common/tool/tool_action.cpp
@@ -26,7 +26,7 @@
 #include <tool/action_manager.h>
 
 TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope,
-        int aDefaultHotKey, const wxString aMenuItem, const wxString& aMenuDesc,
+        int aDefaultHotKey, const wxString& aMenuItem, const wxString& aMenuDesc,
         const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) :
     m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
     m_menuItem( aMenuItem ), m_menuDescription( aMenuDesc ),
diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp
index 6ad1057e1..a899c15cc 100644
--- a/common/widgets/mathplot.cpp
+++ b/common/widgets/mathplot.cpp
@@ -452,7 +452,7 @@ double mpScaleY::P2x( mpWindow& w, double x )
 
 IMPLEMENT_ABSTRACT_CLASS( mpFX, mpLayer )
 
-mpFX::mpFX( wxString name, int flags )
+mpFX::mpFX( const wxString& name, int flags )
 {
     SetName( name );
     m_flags = flags;
@@ -529,7 +529,7 @@ void mpFX::Plot( wxDC& dc, mpWindow& w )
 
 IMPLEMENT_ABSTRACT_CLASS( mpFY, mpLayer )
 
-mpFY::mpFY( wxString name, int flags )
+mpFY::mpFY( const wxString& name, int flags )
 {
     SetName( name );
     m_flags = flags;
@@ -598,7 +598,7 @@ void mpFY::Plot( wxDC& dc, mpWindow& w )
 
 IMPLEMENT_ABSTRACT_CLASS( mpFXY, mpLayer )
 
-mpFXY::mpFXY( wxString name, int flags )
+mpFXY::mpFXY( const wxString& name, int flags )
 {
     SetName( name );
     m_flags     = flags;
@@ -790,7 +790,7 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
 
 IMPLEMENT_ABSTRACT_CLASS( mpProfile, mpLayer )
 
-mpProfile::mpProfile( wxString name, int flags )
+mpProfile::mpProfile( const wxString& name, int flags )
 {
     SetName( name );
     m_flags = flags;
@@ -1273,7 +1273,7 @@ IMPLEMENT_ABSTRACT_CLASS( mpScaleXBase, mpLayer )
 IMPLEMENT_DYNAMIC_CLASS( mpScaleX, mpScaleXBase )
 IMPLEMENT_DYNAMIC_CLASS( mpScaleXLog, mpScaleXBase )
 
-mpScaleXBase::mpScaleXBase( wxString name, int flags, bool ticks, unsigned int type )
+mpScaleXBase::mpScaleXBase( const wxString& name, int flags, bool ticks, unsigned int type )
 {
     SetName( name );
     SetFont( (wxFont&) *wxSMALL_FONT );
@@ -1285,13 +1285,13 @@ mpScaleXBase::mpScaleXBase( wxString name, int flags, bool ticks, unsigned int t
 }
 
 
-mpScaleX::mpScaleX( wxString name, int flags, bool ticks, unsigned int type ) :
+mpScaleX::mpScaleX( const wxString& name, int flags, bool ticks, unsigned int type ) :
     mpScaleXBase( name, flags, ticks, type )
 {
 };
 
 
-mpScaleXLog::mpScaleXLog( wxString name, int flags, bool ticks, unsigned int type ) :
+mpScaleXLog::mpScaleXLog( const wxString& name, int flags, bool ticks, unsigned int type ) :
     mpScaleXBase( name, flags, ticks, type )
 {
 };
@@ -1501,7 +1501,7 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w )
 
 IMPLEMENT_DYNAMIC_CLASS( mpScaleY, mpLayer )
 
-mpScaleY::mpScaleY( wxString name, int flags, bool ticks )
+mpScaleY::mpScaleY( const wxString& name, int flags, bool ticks )
 {
     SetName( name );
     SetFont( (wxFont&) *wxSMALL_FONT );
@@ -3268,7 +3268,7 @@ void mpWindow::SetColourTheme( const wxColour& bgColour,
 IMPLEMENT_DYNAMIC_CLASS( mpFXYVector, mpFXY )
 
 // Constructor
-mpFXYVector::mpFXYVector( wxString name, int flags ) : mpFXY( name, flags )
+mpFXYVector::mpFXYVector( const wxString& name, int flags ) : mpFXY( name, flags )
 {
     m_index = 0;
     // printf("FXYVector::FXYVector!\n");
@@ -3425,7 +3425,7 @@ IMPLEMENT_DYNAMIC_CLASS( mpText, mpLayer )
  *  @param offsetx x position in percentage (0-100)
  *  @param offsetx y position in percentage (0-100)
  */
-mpText::mpText( wxString name, int offsetx, int offsety )
+mpText::mpText( const wxString& name, int offsetx, int offsety )
 {
     SetName( name );
 
diff --git a/eeschema/bom_table_column.cpp b/eeschema/bom_table_column.cpp
index ef270217e..ee14d009f 100644
--- a/eeschema/bom_table_column.cpp
+++ b/eeschema/bom_table_column.cpp
@@ -82,7 +82,7 @@ BOM_COLUMN* BOM_COLUMN_LIST::GetColumnById( unsigned int aColId )
 /**
  * Return a column based on its string title
  */
-BOM_COLUMN* BOM_COLUMN_LIST::GetColumnByTitle( wxString aColTitle )
+BOM_COLUMN* BOM_COLUMN_LIST::GetColumnByTitle( const wxString& aColTitle )
 {
     for( unsigned int ii=0; ii<Columns.size(); ii++ )
     {
@@ -110,7 +110,7 @@ bool BOM_COLUMN_LIST::ContainsColumn( unsigned int aColId )
 /**
  * Test if the list includes a column with the given title
  */
-bool BOM_COLUMN_LIST::ContainsColumn( wxString aColTitle )
+bool BOM_COLUMN_LIST::ContainsColumn( const wxString& aColTitle )
 {
     return nullptr != GetColumnByTitle( aColTitle );
 }
diff --git a/eeschema/bom_table_column.h b/eeschema/bom_table_column.h
index bf8292769..f117adba9 100644
--- a/eeschema/bom_table_column.h
+++ b/eeschema/bom_table_column.h
@@ -138,10 +138,10 @@ public:
 
     BOM_COLUMN* GetColumnByIndex( unsigned int aColIndex );
     BOM_COLUMN* GetColumnById( unsigned int aColId );
-    BOM_COLUMN* GetColumnByTitle( const wxString aColTitle ) ;
+    BOM_COLUMN* GetColumnByTitle( const wxString& aColTitle ) ;
 
     bool ContainsColumn( unsigned int aColId );
-    bool ContainsColumn( const wxString aColTitle );
+    bool ContainsColumn( const wxString& aColTitle );
 
     bool AddColumn( BOM_COLUMN* aCol );
 
diff --git a/eeschema/bom_table_model.cpp b/eeschema/bom_table_model.cpp
index 83885f648..f20752e03 100644
--- a/eeschema/bom_table_model.cpp
+++ b/eeschema/bom_table_model.cpp
@@ -53,7 +53,7 @@ static BOM_TABLE_ROW const* ItemToRow( wxDataViewItem aItem )
     }
 }
 
-BOM_FIELD_VALUES::BOM_FIELD_VALUES( wxString aRefDes, FIELD_VALUE_MAP* aTemplate ) :
+BOM_FIELD_VALUES::BOM_FIELD_VALUES( const wxString& aRefDes, FIELD_VALUE_MAP* aTemplate ) :
         m_refDes( aRefDes ),
         m_templateValues( aTemplate )
 {
@@ -114,7 +114,7 @@ bool BOM_FIELD_VALUES::GetTemplateValue( unsigned int aFieldId, wxString& aValue
  * - There is no current value
  * - The current value is empty
  */
-void BOM_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, wxString aValue, bool aOverwrite )
+void BOM_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, const wxString& aValue, bool aOverwrite )
 {
     if( aOverwrite || m_currentValues.count( aFieldId ) == 0 || m_currentValues[aFieldId].IsEmpty() )
     {
@@ -528,7 +528,7 @@ BOM_TABLE_COMPONENT::BOM_TABLE_COMPONENT( BOM_TABLE_GROUP* aParent,
  * Try to add a unit to this component
  * If the references match, it will be added
  */
-bool BOM_TABLE_COMPONENT::AddUnit( SCH_REFERENCE aUnit )
+bool BOM_TABLE_COMPONENT::AddUnit( const SCH_REFERENCE& aUnit )
 {
     // Addition is successful if the references match or there are currently no units in the group
     if( Units.size() == 0  || Units[0].GetRef().Cmp( aUnit.GetRef() ) == 0 )
diff --git a/eeschema/bom_table_model.h b/eeschema/bom_table_model.h
index e011b1eb8..75bd196a9 100644
--- a/eeschema/bom_table_model.h
+++ b/eeschema/bom_table_model.h
@@ -58,13 +58,13 @@ typedef std::map<unsigned int, wxString> FIELD_VALUE_MAP;
 class BOM_FIELD_VALUES
 {
 public:
-    BOM_FIELD_VALUES( wxString aRefDes, FIELD_VALUE_MAP* aTemplate );
+    BOM_FIELD_VALUES( const wxString& aRefDes, FIELD_VALUE_MAP* aTemplate );
 
     bool GetFieldValue( unsigned int aFieldId, wxString& aValue ) const;
     bool GetBackupValue( unsigned int aFieldId, wxString& aValue ) const;
     bool GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const;
 
-    void SetFieldValue( unsigned int aFieldId, wxString aValue, bool aOverwrite = false );
+    void SetFieldValue( unsigned int aFieldId, const wxString& aValue, bool aOverwrite = false );
 
     wxString GetReference() const { return m_refDes; }
 
@@ -191,7 +191,7 @@ public:
 
     BOM_TABLE_COMPONENT( BOM_TABLE_GROUP* aParent, BOM_COLUMN_LIST* aColumnList, BOM_FIELD_VALUES* aValues );
 
-    bool AddUnit( SCH_REFERENCE aUnit );
+    bool AddUnit( const SCH_REFERENCE& aUnit );
 
     virtual wxString GetFieldValue( unsigned int aFieldId ) const override;
 
diff --git a/eeschema/cmp_tree_model_adapter.cpp b/eeschema/cmp_tree_model_adapter.cpp
index d830a8331..d49808a48 100644
--- a/eeschema/cmp_tree_model_adapter.cpp
+++ b/eeschema/cmp_tree_model_adapter.cpp
@@ -397,7 +397,7 @@ int CMP_TREE_MODEL_ADAPTER::WidthFor( wxString const& aHeading, int aCol )
 
 bool CMP_TREE_MODEL_ADAPTER::FindAndExpand(
         CMP_TREE_NODE& aNode,
-        std::function<bool( CMP_TREE_NODE const* )> aFunc )
+        const std::function<bool( CMP_TREE_NODE const* )>& aFunc )
 {
     for( auto& node: aNode.Children )
     {
diff --git a/eeschema/cmp_tree_model_adapter.h b/eeschema/cmp_tree_model_adapter.h
index a4cc5ec1b..a5df0a6c4 100644
--- a/eeschema/cmp_tree_model_adapter.h
+++ b/eeschema/cmp_tree_model_adapter.h
@@ -350,7 +350,7 @@ private:
      */
     bool FindAndExpand(
             CMP_TREE_NODE& aNode,
-            std::function<bool( CMP_TREE_NODE const* )> aFunc );
+            const std::function<bool( CMP_TREE_NODE const* )>& aFunc );
 
     /**
      * Find and expand successful search results
diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp
index d866414ee..29529a84d 100644
--- a/eeschema/dialogs/dialog_annotate.cpp
+++ b/eeschema/dialogs/dialog_annotate.cpp
@@ -52,7 +52,7 @@ class wxConfigBase;
 class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE
 {
 public:
-    DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, wxString message );
+    DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& message );
 
 
 private:
@@ -98,7 +98,7 @@ private:
 };
 
 
-DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, wxString message )
+DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& message )
     : DIALOG_ANNOTATE_BASE( parent )
 {
     m_Parent = parent;
@@ -310,7 +310,7 @@ int DIALOG_ANNOTATE::GetAnnotateAlgo()
 }
 
 
-int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, wxString message )
+int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& message )
 {
     DIALOG_ANNOTATE dlg( aCaller, message );
 
diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h
index a2692a8da..33f3de42b 100644
--- a/eeschema/invoke_sch_dialog.h
+++ b/eeschema/invoke_sch_dialog.h
@@ -66,7 +66,7 @@ int InvokeDialogRescueEach( SCH_EDIT_FRAME* aCaller, RESCUER& aRescuer, bool aAs
 
 /// Create and show DIALOG_ANNOTATE and return whatever
 /// DIALOG_ANNOTATE::ShowModal() returns.
-int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, wxString message = "" );
+int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& message = "" );
 
 /// Create the modeless DIALOG_ERC and show it, return something to
 /// destroy or close it.  The dialog will have ID_DIALOG_ERC from id.h
diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp
index c757cde90..8380ac691 100644
--- a/eeschema/project_rescue.cpp
+++ b/eeschema/project_rescue.cpp
@@ -186,7 +186,7 @@ static void get_components( std::vector<SCH_COMPONENT*>& aComponents )
  * @param aLibs - the loaded PART_LIBS
  * @param aCached - whether we are looking for the cached part
  */
-static LIB_PART* find_component( wxString aName, PART_LIBS* aLibs, bool aCached )
+static LIB_PART* find_component( const wxString& aName, PART_LIBS* aLibs, bool aCached )
 {
     LIB_PART *part = NULL;
 
diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp
index 77ff9477c..91f485743 100644
--- a/eeschema/sch_component.cpp
+++ b/eeschema/sch_component.cpp
@@ -815,7 +815,7 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
 }
 
 
-wxString SCH_COMPONENT::GetFieldText( wxString aFieldName, bool aIncludeDefaultFields ) const
+wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, bool aIncludeDefaultFields ) const
 {
     // Field name for comparison
     wxString cmpFieldName;
diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h
index 2d6d047f6..2bd550bc2 100644
--- a/eeschema/sch_component.h
+++ b/eeschema/sch_component.h
@@ -324,7 +324,7 @@ public:
      * @param aIncludeDefaultFields is used to search the default library symbol fields in the
      *                              search.
      */
-    wxString GetFieldText( wxString aFieldName, bool aIncludeDefaultFields = true ) const;
+    wxString GetFieldText( const wxString& aFieldName, bool aIncludeDefaultFields = true ) const;
 
     /**
      * Populates a std::vector with SCH_FIELDs.
diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp
index a141d5eb4..1622677d6 100644
--- a/eeschema/sch_field.cpp
+++ b/eeschema/sch_field.cpp
@@ -52,7 +52,7 @@
 #include <kicad_string.h>
 
 
-SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
+SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, const wxString& aName ) :
     SCH_ITEM( aParent, SCH_FIELD_T ),
     EDA_TEXT()
 {
diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h
index fc13b01d4..9a5d817df 100644
--- a/eeschema/sch_field.h
+++ b/eeschema/sch_field.h
@@ -61,7 +61,7 @@ class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
 
 public:
     SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
-               wxString aName = wxEmptyString );
+               const wxString& aName = wxEmptyString );
 
     // Do not create a copy constructor.  The one generated by the compiler is adequate.
 
diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp
index bc2a0f0fe..d17f84df9 100644
--- a/eeschema/sch_sheet_path.cpp
+++ b/eeschema/sch_sheet_path.cpp
@@ -437,7 +437,7 @@ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet )
 }
 
 
-SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString aPath, bool aHumanReadable )
+SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString& aPath, bool aHumanReadable )
 {
     wxString sheetPath;
 
diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h
index ec891b97a..637d146e4 100644
--- a/eeschema/sch_sheet_path.h
+++ b/eeschema/sch_sheet_path.h
@@ -346,7 +346,7 @@ public:
      * @return The sheet that matches \a aPath or NULL if no sheet matching
      *         \a aPath is found.
      */
-    SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
+    SCH_SHEET_PATH* GetSheetByPath( const wxString& aPath, bool aHumanReadable = true );
 
     /**
      * Function IsModified
diff --git a/include/class_board_item.h b/include/class_board_item.h
index a7b03fe19..3bf2a438b 100644
--- a/include/class_board_item.h
+++ b/include/class_board_item.h
@@ -79,7 +79,7 @@ class BOARD_ITEM : public EDA_ITEM
 protected:
     PCB_LAYER_ID    m_Layer;
 
-    static int getTrailingInt( wxString aStr );
+    static int getTrailingInt( const wxString& aStr );
     static int getNextNumberInSequence( const std::set<int>& aSeq, bool aFillSequenceGaps );
 
 public:
diff --git a/include/confirm.h b/include/confirm.h
index 6dab366cf..6af382c63 100644
--- a/include/confirm.h
+++ b/include/confirm.h
@@ -65,7 +65,7 @@ void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime =
  * @param aMessage is the message text to display
  * @param aExtraInfo is extra data that can be optionally displayed in a collapsible pane
  */
-void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString aExtraInfo = wxEmptyString );
+void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
 
 
 /**
@@ -76,7 +76,7 @@ void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxS
  * @param aMessage is the message text to display
  * @param aExtraInfo is the extra data that can be optionally displayed in a collapsible pane
  */
-void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString aExtraInfo = wxEmptyString );
+void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
 
 /**
  * Function IsOK
diff --git a/include/gal/gal_display_options.h b/include/gal/gal_display_options.h
index 606c410dc..55c7e190f 100644
--- a/include/gal/gal_display_options.h
+++ b/include/gal/gal_display_options.h
@@ -66,8 +66,8 @@ namespace KIGFX
     public:
         GAL_DISPLAY_OPTIONS();
 
-        void ReadConfig ( wxConfigBase* aCfg, wxString aBaseName );
-        void WriteConfig( wxConfigBase* aCfg, wxString aBaseName );
+        void ReadConfig ( wxConfigBase* aCfg, const wxString& aBaseName );
+        void WriteConfig( wxConfigBase* aCfg, const wxString& aBaseName );
 
         void NotifyChanged();
 
diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h
index 6a2b189d6..c2e2becd7 100644
--- a/include/gal/opengl/opengl_gal.h
+++ b/include/gal/opengl/opengl_gal.h
@@ -374,7 +374,7 @@ private:
      * @param aPointGetter is a function to obtain coordinates of n-th vertex.
      * @param aPointCount is the number of points to be drawn.
      */
-    void drawPolyline( std::function<VECTOR2D (int)> aPointGetter, int aPointCount );
+    void drawPolyline( const std::function<VECTOR2D (int)>& aPointGetter, int aPointCount );
 
     /**
      * @brief Draws a filled polygon. It does not need the last point to have the same coordinates
diff --git a/include/geometry/shape_file_io.h b/include/geometry/shape_file_io.h
index 78784d74e..919b1e2ba 100644
--- a/include/geometry/shape_file_io.h
+++ b/include/geometry/shape_file_io.h
@@ -48,12 +48,12 @@ class SHAPE_FILE_IO
         SHAPE_FILE_IO( const std::string& aFilename, IO_MODE aMode = IOM_READ );
         ~SHAPE_FILE_IO();
 
-        void BeginGroup( const std::string aName = "<noname>");
+        void BeginGroup( const std::string& aName = "<noname>");
         void EndGroup();
 
         SHAPE* Read();
 
-        void Write( const SHAPE* aShape, const std::string aName = "<noname>" );
+        void Write( const SHAPE* aShape, const std::string& aName = "<noname>" );
 
         void Write( const SHAPE& aShape, const std::string aName = "<noname>" )
         {
diff --git a/include/geometry/shape_poly_set.h b/include/geometry/shape_poly_set.h
index b82dd9de4..832013498 100644
--- a/include/geometry/shape_poly_set.h
+++ b/include/geometry/shape_poly_set.h
@@ -969,7 +969,7 @@ class SHAPE_POLY_SET : public SHAPE
          * @return int -    The minimum distance between aSegment and all the polygons in the set.
          *                  If the point is contained in the polygon, the distance is zero.
          */
-        int Distance( SEG aSegment, int aSegmentWidth = 0 );
+        int Distance( const SEG& aSegment, int aSegmentWidth = 0 );
 
         /**
          * Function IsVertexInHole.
diff --git a/include/search_stack.h b/include/search_stack.h
index 2c6af7808..4133cc78b 100644
--- a/include/search_stack.h
+++ b/include/search_stack.h
@@ -105,7 +105,7 @@ public:
      * @param aPathString is concatonated string with interposing ';' or ':' separators.
      * @return int - the count of paths found in aPathString
      */
-    static int Split( wxArrayString* aResult, const wxString aPathString );
+    static int Split( wxArrayString* aResult, const wxString& aPathString );
 
 #if 1   // this function is so poorly designed it deserves not to exist.
     /**
diff --git a/include/tool/tool_action.h b/include/tool/tool_action.h
index c0d7e4a15..81d9ba2c1 100644
--- a/include/tool/tool_action.h
+++ b/include/tool/tool_action.h
@@ -47,7 +47,7 @@ class TOOL_ACTION
 {
 public:
     TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope = AS_CONTEXT,
-            int aDefaultHotKey = 0, const wxString aMenuItem = wxEmptyString,
+            int aDefaultHotKey = 0, const wxString& aMenuItem = wxEmptyString,
             const wxString& aMenuDesc = wxEmptyString, const BITMAP_OPAQUE* aIcon = NULL,
             TOOL_ACTION_FLAGS aFlags = AF_NONE, void* aParam = NULL );
 
diff --git a/include/widgets/mathplot.h b/include/widgets/mathplot.h
index e0f5bbfba..256522326 100644
--- a/include/widgets/mathplot.h
+++ b/include/widgets/mathplot.h
@@ -525,7 +525,7 @@ public:
     /** @param name  Label
      *  @param flags Label alignment, pass one of #mpALIGN_RIGHT, #mpALIGN_CENTER, #mpALIGN_LEFT.
      */
-    mpFX( wxString name = wxEmptyString, int flags = mpALIGN_RIGHT );
+    mpFX( const wxString& name = wxEmptyString, int flags = mpALIGN_RIGHT );
 
     /** Get function value for argument.
      *  Override this function in your implementation.
@@ -557,7 +557,7 @@ public:
     /** @param name  Label
      *  @param flags Label alignment, pass one of #mpALIGN_BOTTOM, #mpALIGN_CENTER, #mpALIGN_TOP.
      */
-    mpFY( wxString name = wxEmptyString, int flags = mpALIGN_TOP );
+    mpFY( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
 
     /** Get function value for argument.
      *  Override this function in your implementation.
@@ -591,7 +591,7 @@ public:
     /** @param name  Label
      *  @param flags Label alignment, pass one of #mpALIGN_NE, #mpALIGN_NW, #mpALIGN_SW, #mpALIGN_SE.
      */
-    mpFXY( wxString name = wxEmptyString, int flags = mpALIGN_NE );
+    mpFXY( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
 
     /** Rewind value enumeration with mpFXY::GetNextXY.
      *  Override this function in your implementation.
@@ -650,7 +650,7 @@ public:
     /** @param name  Label
      *  @param flags Label alignment, pass one of #mpALIGN_BOTTOM, #mpALIGN_CENTER, #mpALIGN_TOP.
      */
-    mpProfile( wxString name = wxEmptyString, int flags = mpALIGN_TOP );
+    mpProfile( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
 
     /** Get function value for argument.
      *  Override this function in your implementation.
@@ -845,7 +845,7 @@ public:
      *  @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid.
      *  @param type mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.
      */
-    mpScaleXBase( wxString name = wxT("X"), int flags = mpALIGN_CENTER,
+    mpScaleXBase( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
                   bool ticks = true, unsigned int type = mpX_NORMAL );
     virtual ~mpScaleXBase() {};
 
@@ -871,7 +871,7 @@ public:
      *  @param flags Set the position of the scale with respect to the window.
      *  @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid.
      *  @param type mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds. */
-    mpScaleX( wxString name = wxT("X"), int flags = mpALIGN_CENTER,
+    mpScaleX( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
               bool ticks = true, unsigned int type = mpX_NORMAL );
 
     /** Layer plot handler.
@@ -900,7 +900,7 @@ public:
      *  @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid.
      *  @param type mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.
      */
-    mpScaleXLog( wxString name = wxT("log(X)"), int flags = mpALIGN_CENTER,
+    mpScaleXLog( const wxString& name = wxT("log(X)"), int flags = mpALIGN_CENTER,
                  bool ticks = true, unsigned int type = mpX_NORMAL );
 
     virtual double  TransformToPlot( double x ) override;
@@ -942,7 +942,7 @@ public:
      *  @param flags Set position of the scale respect to the window.
      *  @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid
      */
-    mpScaleY( wxString name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true );
+    mpScaleY( const wxString& name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true );
 
     virtual bool IsHorizontal() override { return false; }
 
@@ -1544,7 +1544,7 @@ public:
     /** @param name  Label
      *  @param flags Label alignment, pass one of #mpALIGN_NE, #mpALIGN_NW, #mpALIGN_SW, #mpALIGN_SE.
      */
-    mpFXYVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
+    mpFXYVector( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
 
     virtual ~mpFXYVector() {}
 
@@ -1644,7 +1644,7 @@ public:
     /** @param name text to be drawn in the plot
      *  @param offsetx holds offset for the X location in percentage (0-100)
      *  @param offsety holds offset for the Y location in percentage (0-100) */
-    mpText( wxString name = wxT("Title"), int offsetx = 5, int offsety = 50 );
+    mpText( const wxString& name = wxT("Title"), int offsetx = 5, int offsety = 50 );
 
     /** Text Layer plot handler.
      *  This implementation will plot text adjusted to the visible area. */
diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp
index 89cb8934a..364c8f088 100644
--- a/kicad/commandframe.cpp
+++ b/kicad/commandframe.cpp
@@ -109,7 +109,7 @@ void LAUNCHER_PANEL::CreateCommandToolbar()
  * @param aBitmap is the image to be used
  * @param aToolTip is the button mouse-over tool tip
  */
-void LAUNCHER_PANEL::AddButton( wxWindowID aId, const wxBitmap& aBitmap, wxString aToolTip )
+void LAUNCHER_PANEL::AddButton( wxWindowID aId, const wxBitmap& aBitmap, const wxString& aToolTip )
 {
     wxSize  buttSize( aBitmap.GetWidth() + 2 * BUTTON_EXPANSION,
                       aBitmap.GetHeight() + 2 * BUTTON_EXPANSION );
diff --git a/kicad/kicad.h b/kicad/kicad.h
index 2455750dc..162024edd 100644
--- a/kicad/kicad.h
+++ b/kicad/kicad.h
@@ -333,7 +333,7 @@ private:
      */
     void            CreateCommandToolbar( void );
 
-    void AddButton( wxWindowID aId, const wxBitmap& aBitmap, wxString aToolTip );
+    void AddButton( wxWindowID aId, const wxBitmap& aBitmap, const wxString& aToolTip );
 };
 
 // The C++ project manager includes a single PROJECT in its link image.
diff --git a/lib_dxf/drw_objects.cpp b/lib_dxf/drw_objects.cpp
index 128ab8d2d..6b63eeab3 100644
--- a/lib_dxf/drw_objects.cpp
+++ b/lib_dxf/drw_objects.cpp
@@ -11,6 +11,7 @@
 ******************************************************************************/
 
 #include <iostream>
+#include <utility>
 #include <math.h>
 #include "drw_objects.h"
 #include "intern/dxfreader.h"
@@ -731,7 +732,7 @@ void DRW_ImageDef::parseCode( int code, dxfReader* reader )
 }
 
 
-void DRW_Header::addComment( std::string c )
+void DRW_Header::addComment( const std::string& c )
 {
     if( !comments.empty() )
         comments += '\n';
@@ -1303,7 +1304,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
 }
 
 
-void DRW_Header::addDouble( std::string key, double value, int code )
+void DRW_Header::addDouble( const std::string& key, double value, int code )
 {
     curr = new DRW_Variant();
     curr->addDouble( value );
@@ -1312,7 +1313,7 @@ void DRW_Header::addDouble( std::string key, double value, int code )
 }
 
 
-void DRW_Header::addInt( std::string key, int value, int code )
+void DRW_Header::addInt( const std::string& key, int value, int code )
 {
     curr = new DRW_Variant();
     curr->addInt( value );
@@ -1321,16 +1322,16 @@ void DRW_Header::addInt( std::string key, int value, int code )
 }
 
 
-void DRW_Header::addStr( std::string key, std::string value, int code )
+void DRW_Header::addStr( const std::string& key, std::string value, int code )
 {
     curr = new DRW_Variant();
-    curr->addString( value );
+    curr->addString( std::move(value) );
     curr->code  = code;
     vars[key]   = curr;
 }
 
 
-void DRW_Header::addCoord( std::string key, DRW_Coord value, int code )
+void DRW_Header::addCoord( const std::string& key, DRW_Coord value, int code )
 {
     curr = new DRW_Variant();
     curr->addCoord( value );
@@ -1339,7 +1340,7 @@ void DRW_Header::addCoord( std::string key, DRW_Coord value, int code )
 }
 
 
-bool DRW_Header::getDouble( std::string key, double* varDouble )
+bool DRW_Header::getDouble( const std::string& key, double* varDouble )
 {
     bool result = false;
     std::map<std::string, DRW_Variant*>::iterator it;
@@ -1363,7 +1364,7 @@ bool DRW_Header::getDouble( std::string key, double* varDouble )
 }
 
 
-bool DRW_Header::getInt( std::string key, int* varInt )
+bool DRW_Header::getInt( const std::string& key, int* varInt )
 {
     bool result = false;
     std::map<std::string, DRW_Variant*>::iterator it;
@@ -1387,7 +1388,7 @@ bool DRW_Header::getInt( std::string key, int* varInt )
 }
 
 
-bool DRW_Header::getStr( std::string key, std::string* varStr )
+bool DRW_Header::getStr( const std::string& key, std::string* varStr )
 {
     bool result = false;
     std::map<std::string, DRW_Variant*>::iterator it;
@@ -1411,7 +1412,7 @@ bool DRW_Header::getStr( std::string key, std::string* varStr )
 }
 
 
-bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord )
+bool DRW_Header::getCoord( const std::string& key, DRW_Coord* varCoord )
 {
     bool result = false;
     std::map<std::string, DRW_Variant*>::iterator it;
diff --git a/lib_dxf/drw_objects.h b/lib_dxf/drw_objects.h
index 46c9a3ca1..5de2d6181 100644
--- a/lib_dxf/drw_objects.h
+++ b/lib_dxf/drw_objects.h
@@ -426,22 +426,22 @@ public:
         vars.clear();
     }
 
-    void    addDouble( std::string key, double value, int code );
-    void    addInt( std::string key, int value, int code );
-    void    addStr( std::string key, std::string value, int code );
-    void    addCoord( std::string key, DRW_Coord value, int code );
+    void    addDouble( const std::string& key, double value, int code );
+    void    addInt( const std::string& key, int value, int code );
+    void    addStr( const std::string& key, std::string value, int code );
+    void    addCoord( const std::string& key, DRW_Coord value, int code );
 
     std::string getComments() const { return comments; }
 
     void    parseCode( int code, dxfReader* reader );
     void    write( dxfWriter* writer, DRW::Version ver );
-    void    addComment( std::string c );
+    void    addComment( const std::string& c );
 
 private:
-    bool    getDouble( std::string key, double* varDouble );
-    bool    getInt( std::string key, int* varInt );
-    bool    getStr( std::string key, std::string* varStr );
-    bool    getCoord( std::string key, DRW_Coord* varStr );
+    bool    getDouble( const std::string& key, double* varDouble );
+    bool    getInt( const std::string& key, int* varInt );
+    bool    getStr( const std::string& key, std::string* varStr );
+    bool    getCoord( const std::string& key, DRW_Coord* varStr );
 
 public:
     std::map<std::string, DRW_Variant*> vars;
diff --git a/lib_dxf/intern/drw_textcodec.cpp b/lib_dxf/intern/drw_textcodec.cpp
index b640bc95a..fc587c3a1 100644
--- a/lib_dxf/intern/drw_textcodec.cpp
+++ b/lib_dxf/intern/drw_textcodec.cpp
@@ -235,7 +235,7 @@ std::string DRW_ConvTable::toUtf8( std::string* s )
 }
 
 
-std::string DRW_Converter::encodeText( std::string stmp )
+std::string DRW_Converter::encodeText( const std::string& stmp )
 {
     int code;
 
diff --git a/lib_dxf/intern/drw_textcodec.h b/lib_dxf/intern/drw_textcodec.h
index d6a8977f6..530f72aae 100644
--- a/lib_dxf/intern/drw_textcodec.h
+++ b/lib_dxf/intern/drw_textcodec.h
@@ -43,7 +43,7 @@ public:
     virtual ~DRW_Converter() {}
     virtual std::string fromUtf8( std::string* s ) { return *s; }
     virtual std::string toUtf8( std::string* s );
-    std::string         encodeText( std::string stmp );
+    std::string         encodeText( const std::string& stmp );
     std::string         decodeText( int c );
     std::string         encodeNum( int c );
     int                 decodeNum( std::string s, int* b );
diff --git a/lib_dxf/intern/dxfwriter.cpp b/lib_dxf/intern/dxfwriter.cpp
index fcd9fe7ce..112f8243e 100644
--- a/lib_dxf/intern/dxfwriter.cpp
+++ b/lib_dxf/intern/dxfwriter.cpp
@@ -14,6 +14,7 @@
 #include <fstream>
 #include <string>
 #include <algorithm>
+#include <utility>
 #include "dxfwriter.h"
 
 #ifdef DRW_DBG
@@ -100,7 +101,7 @@
 
 bool dxfWriter::writeUtf8String( int code, std::string text )
 {
-    std::string t = encoder.fromUtf8( text );
+    std::string t = encoder.fromUtf8( std::move(text) );
 
     return writeString( code, t );
 }
@@ -108,7 +109,7 @@ bool dxfWriter::writeUtf8String( int code, std::string text )
 
 bool dxfWriter::writeUtf8Caps( int code, std::string text )
 {
-    std::string strname = text;
+    std::string strname = std::move(text);
     std::transform( strname.begin(), strname.end(), strname.begin(), ::toupper );
     std::string t = encoder.fromUtf8( strname );
 
diff --git a/lib_dxf/libdxfrw.cpp b/lib_dxf/libdxfrw.cpp
index adc8b61a1..3a0da7d27 100644
--- a/lib_dxf/libdxfrw.cpp
+++ b/lib_dxf/libdxfrw.cpp
@@ -1685,7 +1685,7 @@ bool dxfRW::writeViewport( DRW_Viewport* ent )
 }
 
 
-DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, std::string name )
+DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, const std::string& name )
 {
     if( version > DRW::AC1009 )
     {
@@ -1741,7 +1741,7 @@ DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, std::string name )
 }
 
 
-bool dxfRW::writeBlockRecord( std::string name )
+bool dxfRW::writeBlockRecord( const std::string& name )
 {
     if( version > DRW::AC1009 )
     {
diff --git a/lib_dxf/libdxfrw.h b/lib_dxf/libdxfrw.h
index c37dcb2f3..e9e5d47c4 100644
--- a/lib_dxf/libdxfrw.h
+++ b/lib_dxf/libdxfrw.h
@@ -59,14 +59,14 @@ public:
     bool            writeLWPolyline( DRW_LWPolyline* ent );
     bool            writePolyline( DRW_Polyline* ent );
     bool            writeSpline( DRW_Spline* ent );
-    bool            writeBlockRecord( std::string name );
+    bool            writeBlockRecord( const std::string& name );
     bool            writeBlock( DRW_Block* ent );
     bool            writeInsert( DRW_Insert* ent );
     bool            writeMText( DRW_MText* ent );
     bool            writeText( DRW_Text* ent );
     bool            writeHatch( DRW_Hatch* ent );
     bool            writeViewport( DRW_Viewport* ent );
-    DRW_ImageDef*   writeImage( DRW_Image* ent, std::string name );
+    DRW_ImageDef*   writeImage( DRW_Image* ent, const std::string& name );
     bool            writeLeader( DRW_Leader* ent );
     bool            writeDimension( DRW_Dimension* ent );
 
diff --git a/pcb_calculator/datafile_read_write.cpp b/pcb_calculator/datafile_read_write.cpp
index 349dd411d..f8f367ed3 100644
--- a/pcb_calculator/datafile_read_write.cpp
+++ b/pcb_calculator/datafile_read_write.cpp
@@ -177,7 +177,7 @@ PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( LINE_READER* aRe
 }
 
 
-PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, wxString aSource ) :
+PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, const wxString& aSource ) :
     PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
 {
 }
diff --git a/pcb_calculator/datafile_read_write.h b/pcb_calculator/datafile_read_write.h
index ecf303d63..1b05e5247 100644
--- a/pcb_calculator/datafile_read_write.h
+++ b/pcb_calculator/datafile_read_write.h
@@ -56,7 +56,7 @@ class PCB_CALCULATOR_DATAFILE_PARSER : public PCB_CALCULATOR_DATAFILE_LEXER
 {
 public:
     PCB_CALCULATOR_DATAFILE_PARSER( LINE_READER* aReader );
-    PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, wxString aSource );
+    PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, const wxString& aSource );
     LINE_READER* GetReader() { return reader; };
     void Parse( PCB_CALCULATOR_DATAFILE* aDataList );
     void ParseRegulatorDescr( PCB_CALCULATOR_DATAFILE* aDataList );
diff --git a/pcbnew/class_action_plugin.cpp b/pcbnew/class_action_plugin.cpp
index 171e0f2a6..50a05885f 100644
--- a/pcbnew/class_action_plugin.cpp
+++ b/pcbnew/class_action_plugin.cpp
@@ -76,7 +76,7 @@ int ACTION_PLUGINS::GetActionMenu( int aIndex )
 }
 
 
-ACTION_PLUGIN* ACTION_PLUGINS::GetAction( wxString aName )
+ACTION_PLUGIN* ACTION_PLUGINS::GetAction( const wxString& aName )
 {
     int max = GetActionsCount();
 
diff --git a/pcbnew/class_action_plugin.h b/pcbnew/class_action_plugin.h
index 885310752..2d3eeffd2 100644
--- a/pcbnew/class_action_plugin.h
+++ b/pcbnew/class_action_plugin.h
@@ -127,7 +127,7 @@ public:
      * @param aName is the action plugin name
      * @return a action object by it's name or NULL if it isn't available.
      */
-    static ACTION_PLUGIN* GetAction( wxString aName );
+    static ACTION_PLUGIN* GetAction( const wxString& aName );
 
     /**
      * Function SetActionMenu
diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp
index 6cacf21f5..530093682 100644
--- a/pcbnew/class_board_item.cpp
+++ b/pcbnew/class_board_item.cpp
@@ -197,7 +197,7 @@ void BOARD_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
 }
 
 
-int BOARD_ITEM::getTrailingInt( wxString aStr )
+int BOARD_ITEM::getTrailingInt( const wxString& aStr )
 {
     int number = 0;
     int base = 1;
diff --git a/pcbnew/class_footprint_wizard.cpp b/pcbnew/class_footprint_wizard.cpp
index 473007e4d..6787bc25e 100644
--- a/pcbnew/class_footprint_wizard.cpp
+++ b/pcbnew/class_footprint_wizard.cpp
@@ -50,7 +50,7 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex )
 }
 
 
-FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName )
+FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( const wxString& aName )
 {
     int max = GetWizardsCount();
 
diff --git a/pcbnew/class_footprint_wizard.h b/pcbnew/class_footprint_wizard.h
index 69c286ae1..ef82f9228 100644
--- a/pcbnew/class_footprint_wizard.h
+++ b/pcbnew/class_footprint_wizard.h
@@ -204,7 +204,7 @@ public:
      * @param aName is the footprint wizard name
      * @return a wizard object by it's name or NULL if it isn't available.
      */
-    static FOOTPRINT_WIZARD*    GetWizard( wxString aName );
+    static FOOTPRINT_WIZARD*    GetWizard( const wxString& aName );
 
     /**
      * Function GetWizard
diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp
index a23ef28a9..d8f18ee52 100644
--- a/pcbnew/class_module.cpp
+++ b/pcbnew/class_module.cpp
@@ -850,7 +850,7 @@ EDA_ITEM* MODULE::Clone() const
 }
 
 
-void MODULE::RunOnChildren( std::function<void (BOARD_ITEM*)> aFunction )
+void MODULE::RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction )
 {
     try
     {
diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h
index 79431d458..9b1714af0 100644
--- a/pcbnew/class_module.h
+++ b/pcbnew/class_module.h
@@ -569,7 +569,7 @@ public:
      * Invokes a function on all BOARD_ITEMs that belong to the module (pads, drawings, texts).
      * @param aFunction is the function to be invoked.
      */
-    void RunOnChildren( std::function<void (BOARD_ITEM*)> aFunction );
+    void RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction );
 
 
     virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
diff --git a/pcbnew/class_netclass.cpp b/pcbnew/class_netclass.cpp
index 2a4f45663..acacc6b56 100644
--- a/pcbnew/class_netclass.cpp
+++ b/pcbnew/class_netclass.cpp
@@ -95,7 +95,7 @@ NETCLASSES::~NETCLASSES()
 }
 
 
-bool NETCLASSES::Add( NETCLASSPTR aNetClass )
+bool NETCLASSES::Add( const NETCLASSPTR& aNetClass )
 {
     const wxString& name = aNetClass->GetName();
 
diff --git a/pcbnew/class_netclass.h b/pcbnew/class_netclass.h
index 7d35bd13b..cefdf55c7 100644
--- a/pcbnew/class_netclass.h
+++ b/pcbnew/class_netclass.h
@@ -284,7 +284,7 @@ public:
      * @return true if the name within aNetclass is unique and it could be inserted OK,
      *  else false because the name was not unique.
      */
-    bool Add( NETCLASSPTR aNetclass );
+    bool Add( const NETCLASSPTR& aNetclass );
 
     /**
      * Function Remove
diff --git a/pcbnew/class_netinfo.h b/pcbnew/class_netinfo.h
index 3ed89459c..3360f1d45 100644
--- a/pcbnew/class_netinfo.h
+++ b/pcbnew/class_netinfo.h
@@ -117,7 +117,7 @@ public:
      * Function SetClass
      * sets \a aNetclass into this NET
      */
-    void SetClass( NETCLASSPTR aNetClass );
+    void SetClass( const NETCLASSPTR& aNetClass );
 
     NETCLASSPTR GetNetClass()
     {
diff --git a/pcbnew/class_netinfo_item.cpp b/pcbnew/class_netinfo_item.cpp
index 93ee60c29..5c9ec0a5f 100644
--- a/pcbnew/class_netinfo_item.cpp
+++ b/pcbnew/class_netinfo_item.cpp
@@ -78,7 +78,7 @@ void NETINFO_ITEM::Draw( EDA_DRAW_PANEL* panel,
 }
 
 
-void NETINFO_ITEM::SetClass( NETCLASSPTR aNetClass )
+void NETINFO_ITEM::SetClass( const NETCLASSPTR& aNetClass )
 {
     wxCHECK( m_parent, /* void */ );
     m_NetClass = aNetClass ? aNetClass : m_parent->GetDesignSettings().m_NetClasses.GetDefault();
diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp
index 05c34ea94..85eba519a 100644
--- a/pcbnew/clean.cpp
+++ b/pcbnew/clean.cpp
@@ -611,7 +611,7 @@ static bool parallelismTest( int dx1, int dy1, int dx2, int dy2 )
  *  else return NULL
  */
 
-static void updateConn( TRACK *track, std::shared_ptr<CONNECTIVITY_DATA> connectivity )
+static void updateConn( TRACK *track, const std::shared_ptr<CONNECTIVITY_DATA>& connectivity )
 {
     for( auto pad : connectivity->GetConnectedPads( track ) )
     {
diff --git a/pcbnew/connectivity.cpp b/pcbnew/connectivity.cpp
index b1c15a2da..1ca8cab70 100644
--- a/pcbnew/connectivity.cpp
+++ b/pcbnew/connectivity.cpp
@@ -122,7 +122,7 @@ void CONNECTIVITY_DATA::updateRatsnest()
 }
 
 
-void CONNECTIVITY_DATA::addRatsnestCluster( std::shared_ptr<CN_CLUSTER> aCluster )
+void CONNECTIVITY_DATA::addRatsnestCluster( const std::shared_ptr<CN_CLUSTER>& aCluster )
 {
     auto rnNet = m_nets[ aCluster->OriginNet() ];
 
@@ -274,7 +274,7 @@ void CONNECTIVITY_DATA::ComputeDynamicRatsnest( const std::vector<BOARD_ITEM*>&
 
 void CONNECTIVITY_DATA::ClearDynamicRatsnest()
 {
-    m_connAlgo->ForEachAnchor( [] (CN_ANCHOR_PTR anchor ) { anchor->SetNoLine( false ); } );
+    m_connAlgo->ForEachAnchor( [] ( CN_ANCHOR& anchor ) { anchor.SetNoLine( false ); } );
     HideDynamicRatsnest();
 }
 
@@ -352,11 +352,11 @@ const std::list<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetNetItems( int aNetC
     std::set<BOARD_CONNECTED_ITEM*> items;
     std::list<BOARD_CONNECTED_ITEM*> rv;
 
-    m_connAlgo->ForEachItem( [&items, aNetCode, &aTypes] ( CN_ITEM* aItem )
+    m_connAlgo->ForEachItem( [&items, aNetCode, &aTypes] ( CN_ITEM& aItem )
     {
-        if( aItem->Valid() && aItem->Net() == aNetCode )
+        if( aItem.Valid() && ( aItem.Net() == aNetCode ) )
         {
-            KICAD_T itemType = aItem->Parent()->Type();
+            KICAD_T itemType = aItem.Parent()->Type();
 
             for( int i = 0; aTypes[i] > 0; ++i )
             {
@@ -364,7 +364,7 @@ const std::list<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetNetItems( int aNetC
 
                 if( itemType == aTypes[i] )
                 {
-                    items.insert( aItem->Parent() );
+                    items.insert( aItem.Parent() );
                     break;
                 }
             }
diff --git a/pcbnew/connectivity.h b/pcbnew/connectivity.h
index b9df91406..77ad7ad3d 100644
--- a/pcbnew/connectivity.h
+++ b/pcbnew/connectivity.h
@@ -220,7 +220,7 @@ public:
 private:
 
     void    updateRatsnest();
-    void    addRatsnestCluster( std::shared_ptr<CN_CLUSTER> aCluster );
+    void    addRatsnestCluster( const std::shared_ptr<CN_CLUSTER>& aCluster );
 
     std::unique_ptr<CONNECTIVITY_DATA> m_dynamicConnectivity;
     std::shared_ptr<CN_CONNECTIVITY_ALGO> m_connAlgo;
diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp
index 608615957..e2df159ca 100644
--- a/pcbnew/connectivity_algo.cpp
+++ b/pcbnew/connectivity_algo.cpp
@@ -30,7 +30,7 @@
 
 using namespace std::placeholders;
 
-bool operator<( const CN_ANCHOR_PTR a, const CN_ANCHOR_PTR b )
+bool operator<( const CN_ANCHOR_PTR& a, const CN_ANCHOR_PTR& b )
 {
     if( a->Pos().x == b->Pos().x )
         return a->Pos().y < b->Pos().y;
@@ -948,35 +948,35 @@ void CN_CONNECTIVITY_ALGO::Clear()
 }
 
 
-void CN_CONNECTIVITY_ALGO::ForEachItem( std::function<void(CN_ITEM*)> aFunc )
+void CN_CONNECTIVITY_ALGO::ForEachItem( const std::function<void( CN_ITEM& )>& aFunc )
 {
     for( auto item : m_padList )
-        aFunc( item );
+        aFunc( *item );
 
     for( auto item : m_viaList )
-        aFunc( item );
+        aFunc( *item );
 
     for( auto item : m_trackList )
-        aFunc( item );
+        aFunc( *item );
 
     for( auto item : m_zoneList )
-        aFunc( item );
+        aFunc( *item );
 }
 
 
-void CN_CONNECTIVITY_ALGO::ForEachAnchor( std::function<void(CN_ANCHOR_PTR)> aFunc )
+void CN_CONNECTIVITY_ALGO::ForEachAnchor( const std::function<void( CN_ANCHOR& )>& aFunc )
 {
     for( auto anchor : m_padList.Anchors() )
-        aFunc( anchor );
+        aFunc( *anchor );
 
     for( auto anchor : m_viaList.Anchors() )
-        aFunc( anchor );
+        aFunc( *anchor );
 
     for( auto anchor : m_trackList.Anchors() )
-        aFunc( anchor );
+        aFunc( *anchor );
 
     for( auto anchor : m_zoneList.Anchors() )
-        aFunc( anchor );
+        aFunc( *anchor );
 }
 
 
diff --git a/pcbnew/connectivity_algo.h b/pcbnew/connectivity_algo.h
index 38e7b5afb..61869bff7 100644
--- a/pcbnew/connectivity_algo.h
+++ b/pcbnew/connectivity_algo.h
@@ -885,13 +885,13 @@ public:
 
     CN_PAD_LIST& PadList() { return m_padList; }
 
-    void ForEachAnchor(  std::function<void(CN_ANCHOR_PTR)> aFunc );
-    void ForEachItem(  std::function<void(CN_ITEM*)> aFunc );
+    void ForEachAnchor( const std::function<void( CN_ANCHOR& )>& aFunc );
+    void ForEachItem( const std::function<void( CN_ITEM& )>& aFunc );
 
     void MarkNetAsDirty( int aNet );
 
 };
 
-bool operator<( const CN_ANCHOR_PTR a, const CN_ANCHOR_PTR b );
+bool operator<( const CN_ANCHOR_PTR& a, const CN_ANCHOR_PTR& b );
 
 #endif
diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp
index 0110279ed..92684cc68 100644
--- a/pcbnew/dialogs/dialog_create_array.cpp
+++ b/pcbnew/dialogs/dialog_create_array.cpp
@@ -264,7 +264,7 @@ static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry,
  */
 static bool validateLongEntry( const wxTextEntry& entry,
                         long& dest,
-                        const wxString description,
+                        const wxString& description,
                         wxArrayString& errors )
 {
     bool ok = true;
diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp
index 64f5d8f8a..d05f91ff5 100644
--- a/pcbnew/dialogs/dialog_design_rules.cpp
+++ b/pcbnew/dialogs/dialog_design_rules.cpp
@@ -473,7 +473,7 @@ void DIALOG_DESIGN_RULES::InitializeRulesSelectionBoxes()
 /* Initialize the rules list from board
  */
 
-static void class2gridRow( wxGrid* grid, int row, NETCLASSPTR nc )
+static void class2gridRow( wxGrid* grid, int row, const NETCLASSPTR& nc )
 {
     wxString msg;
 
@@ -532,7 +532,7 @@ void DIALOG_DESIGN_RULES::InitRulesList()
 }
 
 
-static void gridRow2class( wxGrid* grid, int row, NETCLASSPTR nc )
+static void gridRow2class( wxGrid* grid, int row, const NETCLASSPTR& nc )
 {
 #define MYCELL( col )   \
     ValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )
diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp
index 6213be96a..a928f1b6c 100644
--- a/pcbnew/drc.cpp
+++ b/pcbnew/drc.cpp
@@ -336,7 +336,7 @@ void DRC::updatePointers()
 }
 
 
-bool DRC::doNetClass( NETCLASSPTR nc, wxString& msg )
+bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg )
 {
     bool ret = true;
 
diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h
index e0f55c2c6..effbcb9e6 100644
--- a/pcbnew/drc_stuff.h
+++ b/pcbnew/drc_stuff.h
@@ -305,7 +305,7 @@ private:
 
     //-----<single "item" tests>-----------------------------------------
 
-    bool doNetClass( std::shared_ptr<NETCLASS> aNetClass, wxString& msg );
+    bool doNetClass( const std::shared_ptr<NETCLASS>& aNetClass, wxString& msg );
 
     /**
      * Function doPadToPadsDrc
diff --git a/pcbnew/footprint_info_impl.cpp b/pcbnew/footprint_info_impl.cpp
index db2d3788a..2eb4a9a7c 100644
--- a/pcbnew/footprint_info_impl.cpp
+++ b/pcbnew/footprint_info_impl.cpp
@@ -66,7 +66,7 @@ void FOOTPRINT_INFO_IMPL::load()
 }
 
 
-bool FOOTPRINT_LIST_IMPL::CatchErrors( std::function<void()> aFunc )
+bool FOOTPRINT_LIST_IMPL::CatchErrors( const std::function<void()>& aFunc )
 {
     try
     {
diff --git a/pcbnew/footprint_info_impl.h b/pcbnew/footprint_info_impl.h
index a2ec466b4..c18a18a54 100644
--- a/pcbnew/footprint_info_impl.h
+++ b/pcbnew/footprint_info_impl.h
@@ -69,7 +69,7 @@ class FOOTPRINT_LIST_IMPL : public FOOTPRINT_LIST
      *
      * @return true if no error occurred.
      */
-    bool CatchErrors( std::function<void()> aFunc );
+    bool CatchErrors( const std::function<void()>& aFunc );
 
 protected:
     virtual void StartWorkers( FP_LIB_TABLE* aTable, wxString const* aNickname,
diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp
index 753e7be4c..05d5c2d38 100644
--- a/pcbnew/footprint_preview_panel.cpp
+++ b/pcbnew/footprint_preview_panel.cpp
@@ -32,6 +32,7 @@
 #include <ki_mutex.h>
 
 #include <boost/bind.hpp>
+#include <utility>
 #include <make_unique.h>
 #include <class_colors_design_settings.h>
 
@@ -103,7 +104,7 @@ class FP_THREAD_IFACE
         void SetCurrentFootprint( LIB_ID aFp )
         {
             MUTLOCK lock( m_lock );
-            m_current_fp = aFp;
+            m_current_fp = std::move(aFp);
         }
 
         /**
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp
index 31ebf5de1..bd44fa71c 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp
@@ -102,7 +102,7 @@ XNODE* FindPinMap( XNODE* aNode )
 }
 
 
-double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConversion )
+double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, const wxString& aActualConversion )
 {
     wxString    ls;
     double      i;
@@ -161,13 +161,13 @@ double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConv
 }
 
 
-int StrToIntUnits( wxString aStr, char aAxe, wxString aActualConversion )
+int StrToIntUnits( const wxString& aStr, char aAxe, const wxString& aActualConversion )
 {
     return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
 }
 
 
-wxString GetAndCutWordWithMeasureUnits( wxString* aStr, wxString aDefaultMeasurementUnit )
+wxString GetAndCutWordWithMeasureUnits( wxString* aStr, const wxString& aDefaultMeasurementUnit )
 {
     wxString result;
 
@@ -206,7 +206,7 @@ wxString GetAndCutWordWithMeasureUnits( wxString* aStr, wxString aDefaultMeasure
 }
 
 
-int StrToInt1Units( wxString aStr )
+int StrToInt1Units( const wxString& aStr )
 {
     double num, precision = 10;
 
@@ -225,10 +225,10 @@ wxString ValidateName( wxString aName )
 }
 
 
-void SetWidth( wxString aStr,
-               wxString aDefaultMeasurementUnit,
-               int*     aWidth,
-               wxString aActualConversion )
+void SetWidth( wxString        aStr,
+               const wxString& aDefaultMeasurementUnit,
+               int*            aWidth,
+               const wxString& aActualConversion )
 {
     *aWidth = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
                                                             aDefaultMeasurementUnit ), wxT( ' ' ),
@@ -236,10 +236,10 @@ void SetWidth( wxString aStr,
 }
 
 
-void SetHeight( wxString    aStr,
-                wxString    aDefaultMeasurementUnit,
-                int*        aHeight,
-                wxString    aActualConversion )
+void SetHeight( wxString        aStr,
+                const wxString& aDefaultMeasurementUnit,
+                int*            aHeight,
+                const wxString& aActualConversion )
 {
     *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
                                                              aDefaultMeasurementUnit ), wxT( ' ' ),
@@ -247,11 +247,11 @@ void SetHeight( wxString    aStr,
 }
 
 
-void SetPosition( wxString  aStr,
-                  wxString  aDefaultMeasurementUnit,
-                  int*      aX,
-                  int*      aY,
-                  wxString  aActualConversion )
+void SetPosition( wxString        aStr,
+                  const wxString& aDefaultMeasurementUnit,
+                  int*            aX,
+                  int*            aY,
+                  const wxString& aActualConversion )
 {
     *aX = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
                                                         aDefaultMeasurementUnit ), wxT( 'X' ),
@@ -262,11 +262,11 @@ void SetPosition( wxString  aStr,
 }
 
 
-void SetDoublePrecisionPosition( wxString   aStr,
-                                 wxString   aDefaultMeasurementUnit,
-                                 double*    aX,
-                                 double*    aY,
-                                 wxString   aActualConversion )
+void SetDoublePrecisionPosition( wxString        aStr,
+                                 const wxString& aDefaultMeasurementUnit,
+                                 double*         aX,
+                                 double*         aY,
+                                 const wxString& aActualConversion )
 {
     *aX = StrToDoublePrecisionUnits( GetAndCutWordWithMeasureUnits( &aStr,
                                                                     aDefaultMeasurementUnit ), wxT( 'X' ),
@@ -276,7 +276,7 @@ void SetDoublePrecisionPosition( wxString   aStr,
                                      aActualConversion );
 }
 
-TTEXT_JUSTIFY GetJustifyIdentificator( wxString aJustify )
+TTEXT_JUSTIFY GetJustifyIdentificator( const wxString& aJustify )
 {
     TTEXT_JUSTIFY id;
 
@@ -302,10 +302,10 @@ TTEXT_JUSTIFY GetJustifyIdentificator( wxString aJustify )
     return id;
 }
 
-void SetTextParameters( XNODE*      aNode,
-                        TTEXTVALUE* aTextValue,
-                        wxString    aDefaultMeasurementUnit,
-                        wxString    aActualConversion )
+void SetTextParameters( XNODE*          aNode,
+                        TTEXTVALUE*     aTextValue,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion )
 {
     XNODE*      tNode;
     wxString    str;
@@ -350,10 +350,10 @@ void SetTextParameters( XNODE*      aNode,
 }
 
 
-void SetFontProperty( XNODE*        aNode,
-                      TTEXTVALUE*   aTextValue,
-                      wxString      aDefaultMeasurementUnit,
-                      wxString      aActualConversion )
+void SetFontProperty( XNODE*          aNode,
+                      TTEXTVALUE*     aTextValue,
+                      const wxString& aDefaultMeasurementUnit,
+                      const wxString& aActualConversion )
 {
     wxString n, propValue;
 
@@ -556,7 +556,7 @@ void SetTextSizeFromStrokeFontHeight( EDA_TEXT* aText, int aTextHeight )
 }
 
 
-XNODE* FindNode( XNODE* aChild, wxString aTag )
+XNODE* FindNode( XNODE* aChild, const wxString& aTag )
 {
     aChild = aChild->GetChildren();
 
@@ -571,7 +571,7 @@ XNODE* FindNode( XNODE* aChild, wxString aTag )
     return NULL;
 }
 
-wxString FindNodeGetContent( XNODE* aChild, wxString aTag )
+wxString FindNodeGetContent( XNODE* aChild, const wxString& aTag )
 {
     wxString str = wxEmptyString;
 
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h
index 5d5a8127f..9a969c647 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h
@@ -66,42 +66,42 @@ typedef struct _TTEXTVALUE
 
 extern wxString     GetWord( wxString* aStr );
 extern XNODE*       FindPinMap( XNODE* aNode );
-extern int          StrToIntUnits( wxString aStr, char aAxe, wxString aActualConversion );
-extern wxString     GetAndCutWordWithMeasureUnits( wxString*    aStr,
-                                                   wxString     aDefaultMeasurementUnit );
-extern int          StrToInt1Units( wxString aStr );
+extern int          StrToIntUnits( const wxString& aStr, char aAxe, const wxString& aActualConversion );
+extern wxString     GetAndCutWordWithMeasureUnits( wxString*       aStr,
+                                                   const wxString& aDefaultMeasurementUnit );
+extern int          StrToInt1Units( const wxString& aStr );
 extern wxString     ValidateName( wxString aName );
-extern void         SetWidth( wxString  aStr,
-                              wxString  aDefaultMeasurementUnit,
-                              int*      aWidth,
-                              wxString  aActualConversion );
-extern void         SetPosition( wxString   aStr,
-                                 wxString   aDefaultMeasurementUnit,
-                                 int*       aX,
-                                 int*       aY,
-                                 wxString   aActualConversion );
-extern void         SetDoublePrecisionPosition( wxString    aStr,
-                                                wxString    aDefaultMeasurementUnit,
-                                                double*     aX,
-                                                double*     aY,
-                                                wxString    aActualConversion );
-extern TTEXT_JUSTIFY GetJustifyIdentificator( wxString aJustify );
-extern void         SetTextParameters( XNODE*       aNode,
-                                       TTEXTVALUE*  aTextValue,
-                                       wxString     aDefaultMeasurementUnit,
-                                       wxString     aActualConversion );
-extern void         SetFontProperty( XNODE*         aNode,
-                                     TTEXTVALUE*    aTextValue,
-                                     wxString       aDefaultMeasurementUnit,
-                                     wxString       aActualConversion );
+extern void         SetWidth( wxString        aStr,
+                              const wxString& aDefaultMeasurementUnit,
+                              int*            aWidth,
+                              const wxString& aActualConversion );
+extern void         SetPosition( wxString        aStr,
+                                 const wxString& aDefaultMeasurementUnit,
+                                 int*            aX,
+                                 int*            aY,
+                                 const wxString& aActualConversion );
+extern void         SetDoublePrecisionPosition( wxString        aStr,
+                                                const wxString& aDefaultMeasurementUnit,
+                                                double*         aX,
+                                                double*         aY,
+                                                const wxString& aActualConversion );
+extern TTEXT_JUSTIFY GetJustifyIdentificator( const wxString& aJustify );
+extern void         SetTextParameters( XNODE*          aNode,
+                                       TTEXTVALUE*     aTextValue,
+                                       const wxString& aDefaultMeasurementUnit,
+                                       const wxString& aActualConversion );
+extern void         SetFontProperty( XNODE*          aNode,
+                                     TTEXTVALUE*     aTextValue,
+                                     const wxString& aDefaultMeasurementUnit,
+                                     const wxString& aActualConversion );
 extern void         SetTextJustify( EDA_TEXT* aText, TTEXT_JUSTIFY aJustify );
 extern int          CalculateTextLengthSize( TTEXTVALUE* aText );
 extern void         CorrectTextPosition( TTEXTVALUE* aValue );
 extern void         SetTextSizeFromStrokeFontHeight( EDA_TEXT* aText,
                                                      int aTextHeight );
 
-extern XNODE*       FindNode( XNODE* aChild, wxString aTag );
-extern wxString     FindNodeGetContent( XNODE* aChild, wxString aTag );
+extern XNODE*       FindNode( XNODE* aChild, const wxString& aTag );
+extern wxString     FindNodeGetContent( XNODE* aChild, const wxString& aTag );
 extern void         InitTTextValue( TTEXTVALUE* aTextValue );
 
 } // namespace PCAD2KICAD
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb.cpp
index 67a360899..a4c49d350 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb.cpp
@@ -133,7 +133,7 @@ int PCB::GetNetCode( wxString aNetName )
     return 0;
 }
 
-XNODE* PCB::FindCompDefName( XNODE* aNode, wxString aName )
+XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName )
 {
     XNODE*      result = NULL, * lNode;
     wxString    propValue;
@@ -162,8 +162,9 @@ XNODE* PCB::FindCompDefName( XNODE* aNode, wxString aName )
 
 
 void PCB::SetTextProperty( XNODE*   aNode, TTEXTVALUE* aTextValue,
-                           wxString aPatGraphRefName, wxString aXmlName,
-                           wxString aActualConversion )
+                           const wxString& aPatGraphRefName,
+                           const wxString& aXmlName,
+                           const wxString& aActualConversion )
 {
     XNODE*      tNode, * t1Node;
     wxString    n, nnew, pn, propValue, str;
@@ -233,7 +234,7 @@ void PCB::SetTextProperty( XNODE*   aNode, TTEXTVALUE* aTextValue,
 
 void PCB::DoPCBComponents( XNODE*           aNode,
                            wxXmlDocument*   aXmlDoc,
-                           wxString         aActualConversion,
+                           const wxString&  aActualConversion,
                            wxStatusBar*     aStatusBar )
 {
     XNODE*        lNode, * tNode, * mNode;
@@ -420,7 +421,9 @@ void PCB::DoPCBComponents( XNODE*           aNode,
 }
 
 
-void PCB::ConnectPinToNet( wxString aCompRef, wxString aPinRef, wxString aNetName )
+void PCB::ConnectPinToNet( const wxString& aCompRef,
+                           const wxString& aPinRef,
+                           const wxString& aNetName )
 {
     PCB_MODULE* module;
     PCB_PAD*    cp;
@@ -447,7 +450,7 @@ void PCB::ConnectPinToNet( wxString aCompRef, wxString aPinRef, wxString aNetNam
 }
 
 
-int PCB::FindLayer( wxString aLayerName )
+int PCB::FindLayer( const wxString& aLayerName )
 {
     for( LAYER_NUM i = 0; i < (int)m_layersStackup.GetCount(); ++i )
     {
@@ -575,7 +578,7 @@ double PCB::GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 )
                   ( aPoint1->y - aPoint2->y ) );
 }
 
-void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, wxString aActualConversion )
+void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion )
 {
     XNODE*       iNode, *lNode, *pNode;
     long         PCadLayer = 0;
@@ -666,7 +669,7 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, wxString aActualConversion )
     }
 }
 
-void PCB::Parse( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, wxString aActualConversion )
+void PCB::Parse( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxString& aActualConversion )
 {
     XNODE*          aNode;//, *aaNode;
     PCB_NET*        net;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb.h b/pcbnew/pcad2kicadpcb_plugin/pcb.h
index 97f6f98ad..6253b116c 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb.h
@@ -53,15 +53,15 @@ public:
     PCB( BOARD* aBoard );
     ~PCB();
 
-    PCB_LAYER_ID        GetKiCadLayer( int aPCadLayer ) override;
+    PCB_LAYER_ID    GetKiCadLayer( int aPCadLayer ) override;
     LAYER_TYPE_T    GetLayerType( int aPCadLayer ) override;
     wxString        GetLayerNetNameRef( int aPCadLayer ) override;
     int             GetNewTimestamp() override;
     int             GetNetCode( wxString aNetName ) override;
 
-    void            Parse( wxStatusBar* aStatusBar,
-                           wxXmlDocument* aXmlDoc,
-                           wxString     aActualConversion );
+    void            Parse( wxStatusBar*    aStatusBar,
+                           wxXmlDocument*  aXmlDoc,
+                           const wxString& aActualConversion );
 
     void            AddToBoard() override;
 
@@ -69,22 +69,25 @@ private:
     int             m_timestamp_cnt;
     wxArrayString   m_layersStackup;
 
-    XNODE*          FindCompDefName( XNODE* aNode, wxString aName );
-    void            SetTextProperty( XNODE*         aNode,
-                                     TTEXTVALUE*    aTextValue,
-                                     wxString       aPatGraphRefName,
-                                     wxString       aXmlName,
-                                     wxString       aActualConversion );
-    void            DoPCBComponents( XNODE*         aNode,
-                                     wxXmlDocument* aXmlDoc,
-                                     wxString       aActualConversion,
-                                     wxStatusBar*   aStatusBar );
-    void            ConnectPinToNet( wxString aCr, wxString aPr, wxString aNetName );
-    int             FindLayer( wxString aLayerName );
+    XNODE*          FindCompDefName( XNODE* aNode, const wxString& aName );
+    void            SetTextProperty( XNODE*          aNode,
+                                     TTEXTVALUE*     aTextValue,
+                                     const wxString& aPatGraphRefName,
+                                     const wxString& aXmlName,
+                                     const wxString& aActualConversion );
+    void            DoPCBComponents( XNODE*          aNode,
+                                     wxXmlDocument*  aXmlDoc,
+                                     const wxString& aActualConversion,
+                                     wxStatusBar*    aStatusBar );
+    void            ConnectPinToNet( const wxString& aCr,
+                                     const wxString& aPr,
+                                     const wxString& aNetName );
+    int             FindLayer( const wxString& aLayerName );
     void            MapLayer( XNODE* aNode );
     int             FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint );
     double          GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 );
-    void            GetBoardOutline( wxXmlDocument* aXmlDoc, wxString aActualConversion );
+    void            GetBoardOutline( wxXmlDocument* aXmlDoc,
+                                     const wxString& aActualConversion );
 };
 
 } // namespace PCAD2KICAD
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp
index 97ca994fa..0b010aecb 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp
@@ -52,10 +52,10 @@ PCB_ARC::~PCB_ARC()
 }
 
 
-void PCB_ARC::Parse( XNODE*     aNode,
-                     int        aLayer,
-                     wxString   aDefaultMeasurementUnit,
-                     wxString   aActualConversion )
+void PCB_ARC::Parse( XNODE*          aNode,
+                     int             aLayer,
+                     const wxString& aDefaultMeasurementUnit,
+                     const wxString& aActualConversion )
 {
     XNODE*      lNode;
     double      a = 0.0;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h
index 2b82409e7..2c8cbf27e 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.h
@@ -47,8 +47,10 @@ public:
     PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_ARC();
 
-    virtual void    Parse( XNODE* aNode, int aLayer,
-                           wxString aDefaultMeasurementUnit, wxString aActualConversion );
+    virtual void    Parse( XNODE* aNode,
+                           int aLayer,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion );
 
     virtual void    SetPosOffset( int aX_offs, int aY_offs ) override;
     virtual void    Flip() override;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp
index 16c7c220f..c4d39e081 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.cpp
@@ -50,10 +50,10 @@ PCB_COPPER_POUR::~PCB_COPPER_POUR()
 }
 
 
-bool PCB_COPPER_POUR::Parse( XNODE*         aNode,
-                             wxString       aDefaultMeasurementUnit,
-                             wxString       aActualConversion,
-                             wxStatusBar*   aStatusBar )
+bool PCB_COPPER_POUR::Parse( XNODE*          aNode,
+                             const wxString& aDefaultMeasurementUnit,
+                             const wxString& aActualConversion,
+                             wxStatusBar*    aStatusBar )
 {
     XNODE*          lNode;
     wxString        pourType, str, propValue;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.h b/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.h
index 5de462efc..c63f196f6 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_copper_pour.h
@@ -44,8 +44,8 @@ public:
     ~PCB_COPPER_POUR();
 
     virtual bool Parse( XNODE*          aNode,
-                        wxString        aDefaultMeasurementUnit,
-                        wxString        aActualConversion,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion,
                         wxStatusBar*    aStatusBar ) override;
 };
 
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.cpp
index 4499783ea..39a0d6fca 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.cpp
@@ -46,9 +46,9 @@ PCB_CUTOUT::~PCB_CUTOUT()
 }
 
 
-bool PCB_CUTOUT::Parse( XNODE*      aNode,
-                        wxString    aDefaultMeasurementUnit,
-                        wxString    aActualConversion )
+bool PCB_CUTOUT::Parse( XNODE*          aNode,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion )
 {
     XNODE*          lNode;
 
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.h b/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.h
index 9f8fa6be9..bda7b8536 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_cutout.h
@@ -43,9 +43,9 @@ public:
     PCB_CUTOUT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
     ~PCB_CUTOUT();
 
-    virtual bool    Parse( XNODE*       aNode,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     actualConversion );
+    virtual bool    Parse( XNODE*          aNode,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& actualConversion );
 };
 
 } // namespace PCAD2KICAD
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.cpp
index d6305b334..8aee07fdb 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.cpp
@@ -49,9 +49,9 @@ PCB_KEEPOUT::~PCB_KEEPOUT()
 }
 
 
-bool PCB_KEEPOUT::Parse( XNODE*         aNode,
-                         wxString       aDefaultMeasurementUnit,
-                         wxString       aActualConversion )
+bool PCB_KEEPOUT::Parse( XNODE*          aNode,
+                         const wxString& aDefaultMeasurementUnit,
+                         const wxString& aActualConversion )
 {
     XNODE*          lNode;
 
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.h b/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.h
index d6b951312..f015a3c7c 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_keepout.h
@@ -43,8 +43,8 @@ public:
     ~PCB_KEEPOUT();
 
     virtual bool Parse( XNODE*          aNode,
-                        wxString        aDefaultMeasurementUnit,
-                        wxString        aActualConversion );
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion );
 };
 
 } // namespace PCAD2KICAD
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp
index bc24d297c..7bcd1d780 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp
@@ -51,10 +51,10 @@ PCB_LINE::~PCB_LINE()
 }
 
 
-void PCB_LINE::Parse( XNODE*        aNode,
-                      int           aLayer,
-                      wxString      aDefaultMeasurementUnit,
-                      wxString      aActualConversion )
+void PCB_LINE::Parse( XNODE*          aNode,
+                      int             aLayer,
+                      const wxString& aDefaultMeasurementUnit,
+                      const wxString& aActualConversion )
 {
     XNODE*      lNode;
     wxString    propValue;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_line.h b/pcbnew/pcad2kicadpcb_plugin/pcb_line.h
index 3bbec94ca..556e88822 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_line.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_line.h
@@ -47,10 +47,10 @@ public:
     PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_LINE();
 
-    virtual void    Parse( XNODE*       aNode,
-                           int          aLayer,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     aActualConversion );
+    virtual void    Parse( XNODE*          aNode,
+                           int             aLayer,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion );
     virtual void    SetPosOffset( int aX_offs, int aY_offs ) override;
     virtual void    Flip() override;
     void            AddToModule( MODULE* aModule ) override;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp
index be3304ac0..65339c1bf 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp
@@ -68,7 +68,7 @@ PCB_MODULE::~PCB_MODULE()
 }
 
 
-XNODE* PCB_MODULE::FindModulePatternDefName( XNODE* aNode, wxString aName )
+XNODE* PCB_MODULE::FindModulePatternDefName( XNODE* aNode, const wxString& aName )
 {
     XNODE*      result, * lNode;
     wxString    propValue1, propValue2;
@@ -218,8 +218,8 @@ void PCB_MODULE::DoLayerContentsObjects( XNODE*                 aNode,
                                          PCB_MODULE*            aPCBModule,
                                          PCB_COMPONENTS_ARRAY*  aList,
                                          wxStatusBar*           aStatusBar,
-                                         wxString               aDefaultMeasurementUnit,
-                                         wxString               aActualConversion )
+                                         const wxString&        aDefaultMeasurementUnit,
+                                         const wxString&        aActualConversion )
 {
     PCB_ARC*            arc;
     PCB_POLYGON*        polygon;
@@ -372,7 +372,7 @@ void PCB_MODULE::DoLayerContentsObjects( XNODE*                 aNode,
 }
 
 
-void PCB_MODULE::SetName( wxString aPin, wxString aName )
+void PCB_MODULE::SetName( const wxString& aPin, const wxString& aName )
 {
     int     i;
     long    num;
@@ -391,7 +391,8 @@ void PCB_MODULE::SetName( wxString aPin, wxString aName )
 
 
 void PCB_MODULE::Parse( XNODE*   aNode, wxStatusBar* aStatusBar,
-                        wxString aDefaultMeasurementUnit, wxString aActualConversion )
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion )
 {
     XNODE*      lNode, * tNode, * mNode;
     PCB_PAD*    pad;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.h b/pcbnew/pcad2kicadpcb_plugin/pcb_module.h
index 356e36b32..c2da5bb69 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.h
@@ -48,19 +48,20 @@ public:
     PCB_MODULE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_MODULE();
 
-    XNODE*      FindModulePatternDefName( XNODE* aNode, wxString aName );
+    XNODE*      FindModulePatternDefName( XNODE* aNode, const wxString& aName );
 
     void        DoLayerContentsObjects( XNODE*                  aNode,
                                         PCB_MODULE*             aPCBModule,
                                         PCB_COMPONENTS_ARRAY*   aList,
                                         wxStatusBar*            aStatusBar,
-                                        wxString                aDefaultMeasurementUnit,
-                                        wxString                aActualConversion );
+                                        const wxString&         aDefaultMeasurementUnit,
+                                        const wxString&         aActualConversion );
 
-    void            SetName( wxString aPin, wxString aName );
+    void            SetName( const wxString& aPin, const wxString& aName );
 
     virtual void    Parse( XNODE*   aNode, wxStatusBar* aStatusBar,
-                           wxString aDefaultMeasurementUnit, wxString aActualConversion );
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion );
 
     virtual void    Flip() override;
     void            AddToBoard() override;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp
index f42e2004f..59b8a2932 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp
@@ -56,8 +56,9 @@ PCB_PAD::~PCB_PAD()
 }
 
 
-void PCB_PAD::Parse( XNODE*   aNode, wxString aDefaultMeasurementUnit,
-                     wxString aActualConversion )
+void PCB_PAD::Parse( XNODE*          aNode,
+                     const wxString& aDefaultMeasurementUnit,
+                     const wxString& aActualConversion )
 {
     XNODE*          lNode, *cNode;
     long            num;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h
index 87e9fccf8..7b6bbe18c 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.h
@@ -48,9 +48,9 @@ public:
     PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_PAD();
 
-    virtual void    Parse( XNODE*       aNode,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     aActualConversion );
+    virtual void    Parse( XNODE*          aNode,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion );
     virtual void    Flip() override;
     void            AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad );
     void            AddToBoard() override;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.cpp
index 699f51fac..82ca1c92e 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.cpp
@@ -50,9 +50,9 @@ PCB_PAD_SHAPE::~PCB_PAD_SHAPE()
 }
 
 
-void PCB_PAD_SHAPE::Parse( XNODE*       aNode,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     aActualConversion )
+void PCB_PAD_SHAPE::Parse( XNODE*          aNode,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion )
 {
     wxString    str, s;
     long        num;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.h b/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.h
index 518f0898d..5398eab2c 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad_shape.h
@@ -47,9 +47,9 @@ public:
     PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_PAD_SHAPE();
 
-    virtual void    Parse( XNODE*       aNode,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     aActualConversion );
+    virtual void    Parse( XNODE*          aNode,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion );
 
     void            AddToBoard() override;
 };
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_plane.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_plane.cpp
index be89e50e0..94fe74ba9 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_plane.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_plane.cpp
@@ -49,10 +49,10 @@ PCB_PLANE::~PCB_PLANE()
 }
 
 
-bool PCB_PLANE::Parse( XNODE*         aNode,
-                       wxString       aDefaultMeasurementUnit,
-                       wxString       aActualConversion,
-                       wxStatusBar*   aStatusBar )
+bool PCB_PLANE::Parse( XNODE*          aNode,
+                       const wxString& aDefaultMeasurementUnit,
+                       const wxString& aActualConversion,
+                       wxStatusBar*    aStatusBar )
 {
     XNODE*          lNode;
     wxString        pourType, str, propValue;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_plane.h b/pcbnew/pcad2kicadpcb_plugin/pcb_plane.h
index 95fbab4f3..5f55f63be 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_plane.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_plane.h
@@ -43,8 +43,8 @@ public:
     ~PCB_PLANE();
 
     virtual bool Parse( XNODE*          aNode,
-                        wxString        aDefaultMeasurementUnit,
-                        wxString        aActualConversion,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion,
                         wxStatusBar*    aStatusBar ) override;
 };
 
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
index 9a5f2530b..8f158d26f 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
@@ -79,7 +79,7 @@ PCB_POLYGON::~PCB_POLYGON()
     }
 }
 
-void PCB_POLYGON::AssignNet( wxString aNetName )
+void PCB_POLYGON::AssignNet( const wxString& aNetName )
 {
     m_net = aNetName;
     m_netCode = GetNetCode( m_net );
@@ -102,7 +102,8 @@ void PCB_POLYGON::SetOutline( VERTICES_ARRAY* aOutline )
 }
 
 void PCB_POLYGON::FormPolygon( XNODE*   aNode, VERTICES_ARRAY* aPolygon,
-                               wxString aDefaultMeasurementUnit, wxString aActualConversion )
+                               const wxString& aDefaultMeasurementUnit,
+                               const wxString& aActualConversion )
 {
     XNODE*      lNode;
     double      x, y;
@@ -123,10 +124,10 @@ void PCB_POLYGON::FormPolygon( XNODE*   aNode, VERTICES_ARRAY* aPolygon,
 }
 
 
-bool PCB_POLYGON::Parse( XNODE*         aNode,
-                         wxString       aDefaultMeasurementUnit,
-                         wxString       aActualConversion,
-                         wxStatusBar*   aStatusBar )
+bool PCB_POLYGON::Parse( XNODE*          aNode,
+                         const wxString& aDefaultMeasurementUnit,
+                         const wxString& aActualConversion,
+                         wxStatusBar*    aStatusBar )
 {
     XNODE*      lNode;
     wxString    propValue;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h
index a37be8fc5..c430d1df2 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.h
@@ -52,8 +52,8 @@ public:
     ~PCB_POLYGON();
 
     virtual bool Parse( XNODE*          aNode,
-                        wxString        aDefaultMeasurementUnit,
-                        wxString        aActualConversion,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion,
                         wxStatusBar*    aStatusBar );
 
     virtual void    SetPosOffset( int aX_offs, int aY_offs ) override;
@@ -61,11 +61,12 @@ public:
     void            AddToBoard() override;
 
 // protected:
-    void            AssignNet( wxString aNetName );
+    void            AssignNet( const wxString& aNetName );
     void            SetOutline( VERTICES_ARRAY* aOutline );
 
     void            FormPolygon( XNODE*   aNode, VERTICES_ARRAY* aPolygon,
-                                 wxString aDefaultMeasurementUnit, wxString actualConversion );
+                                 const wxString& aDefaultMeasurementUnit,
+                                 const wxString& actualConversion );
 protected:
     bool            m_filled;
 };
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp
index b4629f1ed..5cb098541 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp
@@ -48,10 +48,10 @@ PCB_TEXT::~PCB_TEXT()
 }
 
 
-void PCB_TEXT::Parse( XNODE*        aNode,
-                      int           aLayer,
-                      wxString      aDefaultMeasurementUnit,
-                      wxString      aActualConversion )
+void PCB_TEXT::Parse( XNODE*          aNode,
+                      int             aLayer,
+                      const wxString& aDefaultMeasurementUnit,
+                      const wxString& aActualConversion )
 {
     XNODE*      lNode;
     wxString    str;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_text.h b/pcbnew/pcad2kicadpcb_plugin/pcb_text.h
index 1fe856b2c..d623d0503 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_text.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_text.h
@@ -44,10 +44,10 @@ public:
     PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_TEXT();
 
-    virtual void    Parse( XNODE*       aNode,
-                           int          aLayer,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     aActualConversion );
+    virtual void    Parse( XNODE*          aNode,
+                           int             aLayer,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion );
     void            AddToModule( MODULE* aModule ) override;
     void            AddToBoard() override;
 
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_via.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_via.cpp
index 49789d1d5..92ed1e442 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_via.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_via.cpp
@@ -46,8 +46,9 @@ PCB_VIA::~PCB_VIA()
 }
 
 
-void PCB_VIA::Parse( XNODE*   aNode, wxString aDefaultMeasurementUnit,
-                     wxString aActualConversion )
+void PCB_VIA::Parse( XNODE*          aNode,
+                     const wxString& aDefaultMeasurementUnit,
+                     const wxString& aActualConversion )
 {
     XNODE*          lNode, * tNode;
     wxString        propValue;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_via.h b/pcbnew/pcad2kicadpcb_plugin/pcb_via.h
index d29ac7d8f..557c7ac16 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_via.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_via.h
@@ -44,9 +44,9 @@ public:
     PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_VIA();
 
-    virtual void Parse( XNODE*      aNode,
-                        wxString    aDefaultMeasurementUnit,
-                        wxString    aActualConversion ) override;
+    virtual void Parse( XNODE*          aNode,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion ) override;
 };
 
 } // namespace PCAD2KICAD
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.cpp
index 70e6d609c..3aeedf7da 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.cpp
@@ -47,9 +47,9 @@ PCB_VIA_SHAPE::~PCB_VIA_SHAPE()
 }
 
 
-void PCB_VIA_SHAPE::Parse( XNODE*       aNode,
-                           wxString     aDefaultMeasurementUnit,
-                           wxString     aActualConversion )
+void PCB_VIA_SHAPE::Parse( XNODE*          aNode,
+                           const wxString& aDefaultMeasurementUnit,
+                           const wxString& aActualConversion )
 {
     XNODE*      lNode;
     wxString    str;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.h b/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.h
index 9eb222d02..42a5262e3 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_via_shape.h
@@ -42,9 +42,9 @@ public:
     PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
     ~PCB_VIA_SHAPE();
 
-    virtual void Parse( XNODE*      aNode,
-                        wxString    aDefaultMeasurementUnit,
-                        wxString    aActualConversion ) override;
+    virtual void Parse( XNODE*          aNode,
+                        const wxString& aDefaultMeasurementUnit,
+                        const wxString& aActualConversion ) override;
 };
 
 } // namespace PCAD2KICAD
diff --git a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp
index 19ec21db8..74625ba33 100644
--- a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp
@@ -26,9 +26,10 @@
  * @file s_expr_loader.cpp
  */
 
+#include <s_expr_loader.h>
+
 #include <dsnlexer.h>
 #include <macros.h>
-#include <wx/xml/xml.h>
 #include <xnode.h>
 
 namespace PCAD2KICAD {
@@ -36,7 +37,7 @@ namespace PCAD2KICAD {
 static KEYWORD empty_keywords[1] = {};
 static const char ACCEL_ASCII_KEYWORD[] = "ACCEL_ASCII";
 
-void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
+void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc )
 {
     char      line[sizeof( ACCEL_ASCII_KEYWORD )];
     int       tok;
diff --git a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.h b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.h
index 02c1857a0..6076802f0 100644
--- a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.h
+++ b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.h
@@ -29,9 +29,12 @@
 #ifndef S_EXPR_LOADER_H_
 #define S_EXPR_LOADER_H_
 
+#include <wx/wx.h>
+#include <wx/xml/xml.h>
+
 namespace PCAD2KICAD
 {
-    void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc );
+    void LoadInputFile( const wxString& aFileName, wxXmlDocument* aXmlDoc );
 }
 
 #endif    // S_EXPR_LOADER_H_
diff --git a/pcbnew/ratsnest_viewitem.cpp b/pcbnew/ratsnest_viewitem.cpp
index eeb722460..84df786c4 100644
--- a/pcbnew/ratsnest_viewitem.cpp
+++ b/pcbnew/ratsnest_viewitem.cpp
@@ -35,13 +35,14 @@
 #include <layers_id_colors_and_visibility.h>
 
 #include <memory>
+#include <utility>
 
 #include <view/view.h>
 
 namespace KIGFX {
 
 RATSNEST_VIEWITEM::RATSNEST_VIEWITEM(  std::shared_ptr<CONNECTIVITY_DATA> aData ) :
-        EDA_ITEM( NOT_USED ), m_data( aData )
+        EDA_ITEM( NOT_USED ), m_data( std::move(aData) )
 {
 }
 
diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp
index 60889072f..26b4d301a 100644
--- a/pcbnew/router/pns_diff_pair.cpp
+++ b/pcbnew/router/pns_diff_pair.cpp
@@ -423,7 +423,7 @@ static VECTOR2I makeGapVector( VECTOR2I dir, int length )
     return rv;
 }
 
-void DP_GATEWAYS::BuildFromPrimitivePair( DP_PRIMITIVE_PAIR aPair, bool aPreferDiagonal )
+void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool aPreferDiagonal )
 {
     VECTOR2I majorDirection;
     VECTOR2I p0_p, p0_n;
@@ -587,7 +587,7 @@ void DP_GATEWAYS::buildEntries( const VECTOR2I& p0_p, const VECTOR2I& p0_n )
 }
 
 
-void DP_GATEWAYS::buildDpContinuation( DP_PRIMITIVE_PAIR aPair, bool aIsDiagonal )
+void DP_GATEWAYS::buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsDiagonal )
 {
     DP_GATEWAY gw( aPair.AnchorP(), aPair.AnchorN(), aIsDiagonal );
     gw.SetPriority( 100 );
diff --git a/pcbnew/router/pns_diff_pair.h b/pcbnew/router/pns_diff_pair.h
index be074ffc1..25a288e7e 100644
--- a/pcbnew/router/pns_diff_pair.h
+++ b/pcbnew/router/pns_diff_pair.h
@@ -219,7 +219,7 @@ class DP_GATEWAYS
         void BuildForCursor( const VECTOR2I& aCursorPos );
         void BuildOrthoProjections( DP_GATEWAYS &aEntries, const VECTOR2I& aCursorPos, int aOrthoScore );
         void BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool aBuildEntries = false, bool aViaMode = false );
-        void BuildFromPrimitivePair( DP_PRIMITIVE_PAIR aPair, bool aPreferDiagonal );
+        void BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool aPreferDiagonal );
 
         bool FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget, bool aPrefDiagonal, DIFF_PAIR& aDp );
 
@@ -244,7 +244,7 @@ class DP_GATEWAYS
         };
 
         bool checkDiagonalAlignment( const VECTOR2I& a, const VECTOR2I& b ) const;
-        void buildDpContinuation( DP_PRIMITIVE_PAIR aPair, bool aIsDiagonal );
+        void buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsDiagonal );
         void buildEntries( const VECTOR2I& p0_p, const VECTOR2I& p0_n );
 
         int m_gap;
diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp
index e0be21219..dcb322061 100644
--- a/pcbnew/router/pns_kicad_iface.cpp
+++ b/pcbnew/router/pns_kicad_iface.cpp
@@ -83,7 +83,7 @@ private:
     };
 
     int localPadClearance( const PNS::ITEM* aItem ) const;
-    int matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName );
+    int matchDpSuffix( const wxString& aNetName, wxString& aComplementNet, wxString& aBaseDpName );
 
     PNS::ROUTER* m_router;
     BOARD*       m_board;
@@ -224,7 +224,7 @@ void PNS_PCBNEW_RULE_RESOLVER::OverrideClearance( bool aEnable, int aNetA, int a
 }
 
 
-int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName )
+int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( const wxString& aNetName, wxString& aComplementNet, wxString& aBaseDpName )
 {
     int rv = 0;
 
diff --git a/pcbnew/router/pns_logger.cpp b/pcbnew/router/pns_logger.cpp
index 161b800fd..39611c8f4 100644
--- a/pcbnew/router/pns_logger.cpp
+++ b/pcbnew/router/pns_logger.cpp
@@ -72,7 +72,7 @@ void LOGGER::EndGroup()
 }
 
 
-void LOGGER::Log ( const ITEM* aItem, int aKind, const std::string aName )
+void LOGGER::Log ( const ITEM* aItem, int aKind, const std::string& aName )
 {
     m_theLog << "item " << aKind << " " << aName << " ";
     m_theLog << aItem->Net() << " " << aItem->Layers().Start() << " " <<
@@ -122,7 +122,7 @@ void LOGGER::Log ( const ITEM* aItem, int aKind, const std::string aName )
 }
 
 
-void LOGGER::Log( const SHAPE_LINE_CHAIN *aL, int aKind, const std::string aName )
+void LOGGER::Log( const SHAPE_LINE_CHAIN *aL, int aKind, const std::string& aName )
 {
     m_theLog << "item " << aKind << " " << aName << " ";
     m_theLog << 0 << " " << 0 << " " << 0 << " " << 0 << " " << 0;
@@ -134,7 +134,7 @@ void LOGGER::Log( const SHAPE_LINE_CHAIN *aL, int aKind, const std::string aName
 
 
 void LOGGER::Log( const VECTOR2I& aStart, const VECTOR2I& aEnd,
-                      int aKind, const std::string aName)
+                      int aKind, const std::string& aName)
 {
 }
 
diff --git a/pcbnew/router/pns_logger.h b/pcbnew/router/pns_logger.h
index bcc9c91d0..f9c3c410f 100644
--- a/pcbnew/router/pns_logger.h
+++ b/pcbnew/router/pns_logger.h
@@ -48,10 +48,10 @@ public:
     void NewGroup( const std::string& aName, int aIter = 0 );
     void EndGroup();
 
-    void Log( const ITEM* aItem, int aKind = 0, const std::string aName = std::string() );
-    void Log( const SHAPE_LINE_CHAIN *aL, int aKind = 0, const std::string aName = std::string() );
+    void Log( const ITEM* aItem, int aKind = 0, const std::string& aName = std::string() );
+    void Log( const SHAPE_LINE_CHAIN *aL, int aKind = 0, const std::string& aName = std::string() );
     void Log( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aKind = 0,
-              const std::string aName = std::string() );
+              const std::string& aName = std::string() );
 
 private:
     void dumpShape( const SHAPE* aSh );
diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp
index 6bcd06098..86807e583 100644
--- a/pcbnew/specctra.cpp
+++ b/pcbnew/specctra.cpp
@@ -3431,7 +3431,7 @@ void SPECCTRA_DB::doSUPPLY_PIN( SUPPLY_PIN* growth )
 }
 
 
-void SPECCTRA_DB::ExportPCB( wxString aFilename, bool aNameChange )
+void SPECCTRA_DB::ExportPCB( const wxString& aFilename, bool aNameChange )
 {
     if( pcb )
     {
@@ -3445,7 +3445,7 @@ void SPECCTRA_DB::ExportPCB( wxString aFilename, bool aNameChange )
 }
 
 
-void SPECCTRA_DB::ExportSESSION( wxString aFilename )
+void SPECCTRA_DB::ExportSESSION( const wxString& aFilename )
 {
     if( session )
     {
diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h
index 9b0340a2d..512bb98d0 100644
--- a/pcbnew/specctra.h
+++ b/pcbnew/specctra.h
@@ -3816,7 +3816,7 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
      * Function exportNETCLASS
      * exports \a aNetClass to the DSN file.
      */
-    void exportNETCLASS( std::shared_ptr<NETCLASS> aNetClass, BOARD* aBoard );
+    void exportNETCLASS( const std::shared_ptr<NETCLASS>& aNetClass, BOARD* aBoard );
 
     //-----</FromBOARD>------------------------------------------------------
 
@@ -3928,7 +3928,7 @@ public:
      *          and also to to be changed in the output file.
      * @throw IO_ERROR, if an i/o error occurs saving the file.
      */
-    void ExportPCB( wxString aFilename,  bool aNameChange=false );
+    void ExportPCB( const wxString& aFilename,  bool aNameChange=false );
 
     /**
      * Function FromBOARD
@@ -3959,7 +3959,7 @@ public:
      *
      * @param aFilename The file to save to.
      */
-    void ExportSESSION( wxString aFilename );
+    void ExportSESSION( const wxString& aFilename );
 
     /**
      * Function FlipMODULEs
diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp
index 273a94bfb..a8e19cc49 100644
--- a/pcbnew/specctra_export.cpp
+++ b/pcbnew/specctra_export.cpp
@@ -1488,7 +1488,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
 }
 
 
-void SPECCTRA_DB::exportNETCLASS( NETCLASSPTR aNetClass, BOARD* aBoard )
+void SPECCTRA_DB::exportNETCLASS( const NETCLASSPTR& aNetClass, BOARD* aBoard )
 {
     /*  From page 11 of specctra spec:
      *
diff --git a/pcbnew/tools/edit_constraints.cpp b/pcbnew/tools/edit_constraints.cpp
index b73ac0c5a..33b51f449 100644
--- a/pcbnew/tools/edit_constraints.cpp
+++ b/pcbnew/tools/edit_constraints.cpp
@@ -29,6 +29,8 @@
 
 #include <common.h>
 
+#include <utility>
+
 void EC_VERTICAL::Apply( EDIT_POINT& aHandle )
 {
     VECTOR2I point = aHandle.GetPosition();
@@ -178,7 +180,7 @@ void EC_CONVERGING::Apply( EDIT_LINE& aHandle )
 
 
 EC_SNAPLINE::EC_SNAPLINE( EDIT_LINE& aLine, V2D_TRANSFORM_FUN aSnapFun ) :
-    EDIT_CONSTRAINT<EDIT_LINE>( aLine ), m_snapFun( aSnapFun )
+    EDIT_CONSTRAINT<EDIT_LINE>( aLine ), m_snapFun( std::move(aSnapFun) )
 {}
 
 
diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp
index 7c6709544..15bc7b466 100644
--- a/pcbnew/tools/pad_tool.cpp
+++ b/pcbnew/tools/pad_tool.cpp
@@ -37,6 +37,8 @@
 
 #include <dialogs/dialog_global_pads_edition.h>
 
+#include <utility>
+
 #include "pcb_actions.h"
 #include "selection_tool.h"
 #include "pcb_selection_conditions.h"
@@ -71,7 +73,7 @@ public:
     PAD_CONTEXT_MENU( bool aEditingFootprint,
                       SHOW_FUNCTOR aHaveGlobalPadSetting ):
         m_editingFootprint( aEditingFootprint ),
-        m_haveGlobalPadSettings( aHaveGlobalPadSetting )
+        m_haveGlobalPadSettings( std::move(aHaveGlobalPadSetting) )
     {
         SetIcon( pad_xpm );
         SetTitle( _( "Pads" ) );
diff --git a/polygon/poly2tri/sweep/cdt.cc b/polygon/poly2tri/sweep/cdt.cc
index 0cb910b6c..0fd2ac603 100644
--- a/polygon/poly2tri/sweep/cdt.cc
+++ b/polygon/poly2tri/sweep/cdt.cc
@@ -30,17 +30,19 @@
  */
 #include "cdt.h"
 
+#include <utility>
+
 namespace p2t {
 CDT::CDT( std::vector<Point*> polyline )
 {
-    sweep_context_ = new SweepContext( polyline );
+    sweep_context_ = new SweepContext( std::move(polyline) );
     sweep_ = new Sweep;
 }
 
 
 void CDT::AddHole( std::vector<Point*> polyline )
 {
-    sweep_context_->AddHole( polyline );
+    sweep_context_->AddHole( std::move(polyline) );
 }
 
 
diff --git a/polygon/poly2tri/sweep/sweep_context.cc b/polygon/poly2tri/sweep/sweep_context.cc
index 012421560..63d148969 100644
--- a/polygon/poly2tri/sweep/sweep_context.cc
+++ b/polygon/poly2tri/sweep/sweep_context.cc
@@ -30,6 +30,7 @@
  */
 #include "sweep_context.h"
 #include <algorithm>
+#include <utility>
 #include "advancing_front.h"
 
 namespace p2t {
@@ -44,7 +45,7 @@ SweepContext::SweepContext( std::vector<Point*> polyline ) :
     basin = Basin();
     edge_event = EdgeEvent();
 
-    points_ = polyline;
+    points_ = std::move(polyline);
 
     InitEdges( points_ );
 }
diff --git a/utils/idftools/dxf2idf.cpp b/utils/idftools/dxf2idf.cpp
index c921365b7..7c4571bf9 100644
--- a/utils/idftools/dxf2idf.cpp
+++ b/utils/idftools/dxf2idf.cpp
@@ -49,7 +49,7 @@ DXF2IDF::~DXF2IDF()
 }
 
 
-bool DXF2IDF::ReadDxf( const std::string aFile )
+bool DXF2IDF::ReadDxf( const std::string& aFile )
 {
     dxfRW* reader = new dxfRW( aFile.c_str() );
 
diff --git a/utils/idftools/dxf2idf.h b/utils/idftools/dxf2idf.h
index 6b6d0bcd4..59b968004 100644
--- a/utils/idftools/dxf2idf.h
+++ b/utils/idftools/dxf2idf.h
@@ -41,7 +41,7 @@ public:
     DXF2IDF() : m_scale( 1.0 ) {};
     ~DXF2IDF();
 
-    bool ReadDxf( const std::string aFile );
+    bool ReadDxf( const std::string& aFile );
     bool WriteOutline( FILE* aFile, bool isInch );
 
 private:
diff --git a/utils/idftools/idf_common.cpp b/utils/idftools/idf_common.cpp
index b742c1207..a4b522b80 100644
--- a/utils/idftools/idf_common.cpp
+++ b/utils/idftools/idf_common.cpp
@@ -330,8 +330,8 @@ IDF_DRILL_DATA::IDF_DRILL_DATA()
 
 IDF_DRILL_DATA::IDF_DRILL_DATA( double aDrillDia, double aPosX, double aPosY,
                                 IDF3::KEY_PLATING aPlating,
-                                const std::string aRefDes,
-                                const std::string aHoleType,
+                                const std::string& aRefDes,
+                                const std::string& aHoleType,
                                 IDF3::KEY_OWNER aOwner )
 {
     if( aDrillDia < 0.3 )
diff --git a/utils/idftools/idf_common.h b/utils/idftools/idf_common.h
index 8e29f5531..8dda141a9 100644
--- a/utils/idftools/idf_common.h
+++ b/utils/idftools/idf_common.h
@@ -401,8 +401,8 @@ public:
      */
     IDF_DRILL_DATA( double aDrillDia, double aPosX, double aPosY,
                     IDF3::KEY_PLATING aPlating,
-                    const std::string aRefDes,
-                    const std::string aHoleType,
+                    const std::string& aRefDes,
+                    const std::string& aHoleType,
                     IDF3::KEY_OWNER aOwner );
 
     /**
diff --git a/utils/idftools/idf_outlines.cpp b/utils/idftools/idf_outlines.cpp
index a53ea200f..1cef84e22 100644
--- a/utils/idftools/idf_outlines.cpp
+++ b/utils/idftools/idf_outlines.cpp
@@ -25,6 +25,7 @@
 #include <iomanip>
 #include <sstream>
 #include <cmath>
+#include <utility>
 
 #include <idf_helpers.h>
 #include <idf_outlines.h>
@@ -1556,7 +1557,7 @@ OTHER_OUTLINE::OTHER_OUTLINE( IDF3_BOARD* aParent )
     return;
 }
 
-bool OTHER_OUTLINE::SetOutlineIdentifier( const std::string aUniqueID )
+bool OTHER_OUTLINE::SetOutlineIdentifier( const std::string& aUniqueID )
 {
 #ifndef DISABLE_IDF_OWNERSHIP
     if( !CheckOwnership( __LINE__, __FUNCTION__, parent, owner, outlineType, errormsg ) )
@@ -2730,7 +2731,7 @@ bool GROUP_OUTLINE::SetGroupName( std::string aGroupName )
         return false;
 #endif
 
-    groupName = aGroupName;
+    groupName = std::move(aGroupName);
 
     return true;
 }
diff --git a/utils/idftools/idf_outlines.h b/utils/idftools/idf_outlines.h
index 74149ab4f..36f190513 100644
--- a/utils/idftools/idf_outlines.h
+++ b/utils/idftools/idf_outlines.h
@@ -382,7 +382,7 @@ public:
      * sets the Outline Identifier string of this OTHER_OUTLINE object
      * as per IDFv3 spec.
      */
-    virtual bool SetOutlineIdentifier( const std::string aUniqueID );
+    virtual bool SetOutlineIdentifier( const std::string& aUniqueID );
 
     /**
      * Function GetOutlineIdentifier
diff --git a/utils/idftools/idf_parser.cpp b/utils/idftools/idf_parser.cpp
index fc159f328..3ea410e4e 100644
--- a/utils/idftools/idf_parser.cpp
+++ b/utils/idftools/idf_parser.cpp
@@ -28,6 +28,7 @@
 #include <cmath>
 #include <cerrno>
 #include <algorithm>
+#include <utility>
 #include <wx/string.h>
 #include <wx/filename.h>
 
@@ -717,7 +718,7 @@ bool IDF3_COMP_OUTLINE_DATA::readPlaceData( std::istream &aBoardFile,
 
 void IDF3_COMP_OUTLINE_DATA::writePlaceData( std::ostream& aBoardFile,
                                              double aXpos, double aYpos, double aAngle,
-                                             const std::string aRefDes,
+                                             const std::string& aRefDes,
                                              IDF3::IDF_PLACEMENT aPlacement,
                                              IDF3::IDF_LAYER aSide )
 {
@@ -988,7 +989,7 @@ const std::string& IDF3_COMPONENT::GetRefDes( void )
 
 IDF_DRILL_DATA* IDF3_COMPONENT::AddDrill( double aDia, double aXpos, double aYpos,
                                           IDF3::KEY_PLATING aPlating,
-                                          const std::string aHoleType,
+                                          const std::string& aHoleType,
                                           IDF3::KEY_OWNER aOwner )
 {
     IDF_DRILL_DATA* dp = new IDF_DRILL_DATA( aDia, aXpos, aYpos, aPlating,
@@ -1422,7 +1423,7 @@ IDF3::CAD_TYPE IDF3_BOARD::GetCadType( void )
 
 void IDF3_BOARD::SetBoardName( std::string aBoardName )
 {
-    boardName = aBoardName;
+    boardName = std::move(aBoardName);
     return;
 }
 
@@ -3405,7 +3406,7 @@ const std::list< IDF_OUTLINE* >*const IDF3_BOARD::GetBoardOutlines( void )
 
 IDF_DRILL_DATA* IDF3_BOARD::AddBoardDrill( double aDia, double aXpos, double aYpos,
                                    IDF3::KEY_PLATING aPlating,
-                                   const std::string aHoleType,
+                                   const std::string& aHoleType,
                                    IDF3::KEY_OWNER aOwner )
 {
     IDF_DRILL_DATA* drill = new IDF_DRILL_DATA( aDia, aXpos, aYpos, aPlating,
@@ -3599,7 +3600,7 @@ bool IDF3_BOARD::AddSlot( double aWidth, double aLength, double aOrientation, do
 
 IDF_DRILL_DATA* IDF3_BOARD::addCompDrill( double aDia, double aXpos, double aYpos,
                                   IDF3::KEY_PLATING aPlating,
-                                  const std::string aHoleType,
+                                  const std::string& aHoleType,
                                   IDF3::KEY_OWNER aOwner,
                                   const std::string& aRefDes )
 {
@@ -3723,7 +3724,7 @@ IDF_DRILL_DATA* IDF3_BOARD::addCompDrill( IDF_DRILL_DATA* aDrilledHole )
 }
 
 
-bool IDF3_BOARD::delCompDrill( double aDia, double aXpos, double aYpos, std::string aRefDes )
+bool IDF3_BOARD::delCompDrill( double aDia, double aXpos, double aYpos, const std::string& aRefDes )
 {
     errormsg.clear();
 
@@ -3831,7 +3832,7 @@ std::map< std::string, IDF3_COMPONENT* >*const IDF3_BOARD::GetComponents( void )
 }
 
 
-IDF3_COMPONENT* IDF3_BOARD::FindComponent( std::string aRefDes )
+IDF3_COMPONENT* IDF3_BOARD::FindComponent( const std::string& aRefDes )
 {
     std::map<std::string, IDF3_COMPONENT*>::iterator it = components.find( aRefDes );
 
@@ -3844,7 +3845,7 @@ IDF3_COMPONENT* IDF3_BOARD::FindComponent( std::string aRefDes )
 
 // returns a pointer to a component outline object or NULL
 // if the object doesn't exist
-IDF3_COMP_OUTLINE* IDF3_BOARD::GetComponentOutline( wxString aFullFileName )
+IDF3_COMP_OUTLINE* IDF3_BOARD::GetComponentOutline( const wxString& aFullFileName )
 {
     std::string fname = TO_UTF8( aFullFileName );
     wxFileName idflib( aFullFileName );
@@ -4054,7 +4055,7 @@ IDF3_COMP_OUTLINE* IDF3_BOARD::GetComponentOutline( wxString aFullFileName )
 
 // returns a pointer to the component outline object with the
 // unique ID aComponentID
-IDF3_COMP_OUTLINE* IDF3_BOARD::GetComponentOutline( std::string aComponentID )
+IDF3_COMP_OUTLINE* IDF3_BOARD::GetComponentOutline( const std::string& aComponentID )
 {
     std::map< std::string, IDF3_COMP_OUTLINE*>::iterator its = compOutlines.find( aComponentID );
 
diff --git a/utils/idftools/idf_parser.h b/utils/idftools/idf_parser.h
index b64fcf8b0..c3b25c95e 100644
--- a/utils/idftools/idf_parser.h
+++ b/utils/idftools/idf_parser.h
@@ -110,7 +110,7 @@ private:
      * @return bool: true if data was successfully written, otherwise false
      */
     void writePlaceData( std::ostream& aBoardFile, double aXpos, double aYpos, double aAngle,
-                         const std::string aRefDes, IDF3::IDF_PLACEMENT aPlacement,
+                         const std::string& aRefDes, IDF3::IDF_PLACEMENT aPlacement,
                          IDF3::IDF_LAYER aSide );
 
 public:
@@ -318,7 +318,7 @@ public:
      */
     IDF_DRILL_DATA* AddDrill( double aDia, double aXpos, double aYpos,
                               IDF3::KEY_PLATING aPlating,
-                              const std::string aHoleType,
+                              const std::string& aHoleType,
                               IDF3::KEY_OWNER aOwner );
 
     /**
@@ -516,13 +516,13 @@ private:
 
     IDF_DRILL_DATA* addCompDrill( double aDia, double aXpos, double aYpos,
                                   IDF3::KEY_PLATING aPlating,
-                                  const std::string aHoleType,
+                                  const std::string& aHoleType,
                                   IDF3::KEY_OWNER aOwner,
                                   const std::string& aRefDes );
 
     IDF_DRILL_DATA* addCompDrill( IDF_DRILL_DATA* aDrilledHole );
 
-    bool delCompDrill( double aDia, double aXpos, double aYpos, std::string aRefDes );
+    bool delCompDrill( double aDia, double aXpos, double aYpos, const std::string& aRefDes );
 
     // read the DRILLED HOLES section
     void readBrdDrills( std::istream& aBoardFile, IDF3::FILE_STATE& aBoardState );
@@ -676,7 +676,7 @@ public:
 
     IDF_DRILL_DATA* AddBoardDrill( double aDia, double aXpos, double aYpos,
                                    IDF3::KEY_PLATING aPlating,
-                                   const std::string aHoleType,
+                                   const std::string& aHoleType,
                                    IDF3::KEY_OWNER aOwner );
 
     IDF_DRILL_DATA* AddDrill( IDF_DRILL_DATA* aDrilledHole );
@@ -693,15 +693,15 @@ public:
     bool DelComponent( size_t aIndex );
     size_t GetComponentsSize( void );
     std::map< std::string, IDF3_COMPONENT* >*const GetComponents( void );
-    IDF3_COMPONENT* FindComponent( std::string aRefDes );
+    IDF3_COMPONENT* FindComponent( const std::string& aRefDes );
 
     // returns a pointer to a component outline object or NULL
     // if the object doesn't exist
-    IDF3_COMP_OUTLINE* GetComponentOutline( wxString aFullFileName );
+    IDF3_COMP_OUTLINE* GetComponentOutline( const wxString& aFullFileName );
 
     // returns a pointer to the component outline object with the
     // unique ID aComponentID
-    IDF3_COMP_OUTLINE* GetComponentOutline( std::string aComponentID );
+    IDF3_COMP_OUTLINE* GetComponentOutline( const std::string& aComponentID );
 
     // returns a pointer to the outline "NOGEOM NOPART" which is substituted
     // whenever a true outline cannot be found or is defective

--------------2.13.5--


From 72d635a4866efd98dc318148f79bac08cf428b5a Mon Sep 17 00:00:00 2001
From: Camille <camille019@xxxxxxxxxxx>
Date: Fri, 22 Sep 2017 19:11:11 +0200
Subject: [PATCH 1/4] Fix unnecessary copy initialization detected by
 clang-tidy
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.13.5"

This is a multi-part message in MIME format.
--------------2.13.5
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 common/gestfich.cpp                                    | 10 +++++-----
 cvpcb/dialogs/fp_conflict_assignment_selector.cpp      |  2 +-
 eeschema/netlist_exporters/netlist_exporter_pspice.cpp |  2 +-
 eeschema/plot_schematic_PDF.cpp                        |  2 +-
 gerbview/printout_control.cpp                          |  2 +-
 kicad/tree_project_frame.cpp                           |  8 ++++----
 pcbnew/board_netlist_updater.cpp                       |  2 +-
 pcbnew/class_board.cpp                                 |  2 +-
 pcbnew/dialogs/dialog_create_array.cpp                 |  2 +-
 pcbnew/loadcmp.cpp                                     | 10 +++++-----
 pcbnew/printout_controler.cpp                          |  2 +-
 pcbnew/router/pns_line_placer.cpp                      |  2 +-
 plugins/3d/vrml/x3d.cpp                                |  2 +-
 plugins/3d/vrml/x3d/x3d_appearance.cpp                 |  4 ++--
 plugins/3d/vrml/x3d/x3d_coords.cpp                     |  2 +-
 plugins/3d/vrml/x3d/x3d_ifaceset.cpp                   |  2 +-
 plugins/3d/vrml/x3d/x3d_ops.cpp                        | 10 +++++-----
 plugins/3d/vrml/x3d/x3d_shape.cpp                      |  2 +-
 plugins/3d/vrml/x3d/x3d_transform.cpp                  |  2 +-
 19 files changed, 35 insertions(+), 35 deletions(-)


--------------2.13.5
Content-Type: text/x-patch; name="0001-Fix-unnecessary-copy-initialization-detected-by-clan.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Fix-unnecessary-copy-initialization-detected-by-clan.patch"

diff --git a/common/gestfich.cpp b/common/gestfich.cpp
index 4e6fea79a..326d98188 100644
--- a/common/gestfich.cpp
+++ b/common/gestfich.cpp
@@ -392,17 +392,17 @@ bool OpenPDF( const wxString& file )
 void OpenFile( const wxString& file )
 {
     wxString    command;
-    wxString    filename = file;
 
-    wxFileName  CurrentFileName( filename );
-    wxString    ext, type;
+    wxFileName  currentFileName( file );
+    wxString    ext;
+    wxString    type;
 
-    ext = CurrentFileName.GetExt();
+    ext = currentFileName.GetExt();
     wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
 
     bool        success = false;
 
-    wxFileType::MessageParameters params( filename, type );
+    wxFileType::MessageParameters params( file, type );
 
     if( filetype )
         success = filetype->GetOpenCommand( &command, params );
diff --git a/cvpcb/dialogs/fp_conflict_assignment_selector.cpp b/cvpcb/dialogs/fp_conflict_assignment_selector.cpp
index ef2f18002..0e5b372ee 100644
--- a/cvpcb/dialogs/fp_conflict_assignment_selector.cpp
+++ b/cvpcb/dialogs/fp_conflict_assignment_selector.cpp
@@ -79,7 +79,7 @@ void DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::OnColumnClick( wxListEvent& event )
     // when it is the COL_SELCMP column, set all item choices to cmp file assigment.
     // when it is the COL_SELSCH column, set all item choices to schematic assigment.
 
-    wxListItem item = event.GetItem();
+    const wxListItem& item = event.GetItem();
 
     int column = event.GetColumn();
     int colclr, colset;
diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp
index badb91e98..66af766ce 100644
--- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp
+++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp
@@ -318,7 +318,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
             if( fieldSeq )
             {
                 // Get the string containing the sequence of nodes:
-                wxString nodeSeqIndexLineStr = fieldSeq->GetText();
+                const wxString& nodeSeqIndexLineStr = fieldSeq->GetText();
 
                 // Verify field exists and is not empty:
                 if( !nodeSeqIndexLineStr.IsEmpty() )
diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp
index 2d679a8d7..87e9fe60a 100644
--- a/eeschema/plot_schematic_PDF.cpp
+++ b/eeschema/plot_schematic_PDF.cpp
@@ -165,7 +165,7 @@ void DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF( PLOTTER * aPlotter, SCH_SCREEN* aS
 {
     PAGE_INFO   plotPage;                               // page size selected to plot
     // Considerations on page size and scaling requests
-    PAGE_INFO   actualPage = aScreen->GetPageSettings(); // page size selected in schematic
+    const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
 
     switch( m_pageSizeSelect )
     {
diff --git a/gerbview/printout_control.cpp b/gerbview/printout_control.cpp
index 21a758c2c..c80fe3af4 100644
--- a/gerbview/printout_control.cpp
+++ b/gerbview/printout_control.cpp
@@ -134,7 +134,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage( const wxString& aLayerName,
     wxBusyCursor  dummy;
 
     boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetGerberLayoutBoundingBox();
-    wxString titleblockFilename = aLayerName;    // TODO see if we uses the gerber file name
+    const wxString& titleblockFilename = aLayerName;    // TODO see if we uses the gerber file name
 
     // Use the page size as the drawing area when the board is shown or the user scale
     // is less than 1.
diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp
index a3d999201..646e4cc29 100644
--- a/kicad/tree_project_frame.cpp
+++ b/kicad/tree_project_frame.cpp
@@ -922,7 +922,7 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
 
 void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
 {
-    wxFileName pathModified = event.GetPath();
+    const wxFileName& pathModified = event.GetPath();
     wxString subdir = pathModified.GetPath();
     wxString fn = pathModified.GetFullPath();
 
@@ -973,8 +973,8 @@ void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
 
     case wxFSW_EVENT_RENAME :
         {
-            wxFileName  newpath = event.GetNewPath();
-            wxString    newfn = newpath.GetFullPath();
+            const wxFileName& newpath = event.GetNewPath();
+            wxString newfn = newpath.GetFullPath();
 
             while( kid.IsOk() )
             {
@@ -1060,7 +1060,7 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
         if( itemData && itemData->GetType() == TREE_DIRECTORY )
         {
             // we can see wxString under a debugger, not a wxFileName
-            wxString path = itemData->GetFileName();
+            const wxString& path = itemData->GetFileName();
 
             wxLogDebug( "%s: add '%s'\n", __func__, TO_UTF8( path ) );
 
diff --git a/pcbnew/board_netlist_updater.cpp b/pcbnew/board_netlist_updater.cpp
index c3b705ae8..3ce17bddc 100644
--- a/pcbnew/board_netlist_updater.cpp
+++ b/pcbnew/board_netlist_updater.cpp
@@ -573,7 +573,7 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
         // Explore all pins/pads in component
         for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
         {
-            COMPONENT_NET net = component->GetNet( jj );
+            const COMPONENT_NET& net = component->GetNet( jj );
             padname = net.GetPinName();
 
             if( footprint->FindPadByName( padname ) )
diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp
index a68a4e819..f7339edb6 100644
--- a/pcbnew/class_board.cpp
+++ b/pcbnew/class_board.cpp
@@ -2770,7 +2770,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
             // Explore all pins/pads in component
             for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
             {
-                COMPONENT_NET net = component->GetNet( jj );
+                const COMPONENT_NET& net = component->GetNet( jj );
                 padname = net.GetPinName();
 
                 if( footprint->FindPadByName( padname ) )
diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp
index d7600b6c3..0110279ed 100644
--- a/pcbnew/dialogs/dialog_create_array.cpp
+++ b/pcbnew/dialogs/dialog_create_array.cpp
@@ -175,7 +175,7 @@ static bool getNumberingOffset( const wxString& str,
         DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type,
         int& offsetToFill )
 {
-    const wxString alphabet = alphabetFromNumberingScheme( type );
+    const wxString& alphabet = alphabetFromNumberingScheme( type );
 
     int offset = 0;
     const int radix = alphabet.length();
diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp
index 31f64f072..053ae6e4a 100644
--- a/pcbnew/loadcmp.cpp
+++ b/pcbnew/loadcmp.cpp
@@ -165,11 +165,11 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
                                                bool            aUseFootprintViewer,
                                                wxDC*           aDC )
 {
-    MODULE*     module = NULL;
-    wxPoint     curspos = GetCrossHairPosition();
-    wxString    moduleName, keys;
-    wxString    libName = aLibrary;
-    bool        allowWildSeach = true;
+    MODULE*         module = NULL;
+    wxPoint         curspos = GetCrossHairPosition();
+    wxString        moduleName, keys;
+    const wxString& libName = aLibrary;
+    bool            allowWildSeach = true;
 
     static wxArrayString HistoryList;
     static wxString      lastComponentName;
diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp
index 416a2bf01..a77bd21dd 100644
--- a/pcbnew/printout_controler.cpp
+++ b/pcbnew/printout_controler.cpp
@@ -156,7 +156,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage( const wxString& aLayerName, int aPageN
 
     BOARD* brd = ((PCB_BASE_FRAME*) m_Parent)->GetBoard();
     boardBoundingBox = brd->ComputeBoundingBox();
-    wxString titleblockFilename = brd->GetFileName();
+    const wxString& titleblockFilename = brd->GetFileName();
 
     // Use the page size as the drawing area when the board is shown or the user scale
     // is less than 1.
diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp
index f1cd748e1..a960bc287 100644
--- a/pcbnew/router/pns_line_placer.cpp
+++ b/pcbnew/router/pns_line_placer.cpp
@@ -438,7 +438,7 @@ bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead )
 
 const LINE LINE_PLACER::reduceToNearestObstacle( const LINE& aOriginalLine )
 {
-    auto l0  = aOriginalLine.CLine();
+    const auto& l0 = aOriginalLine.CLine();
 
     if ( !l0.PointCount() )
         return aOriginalLine;
diff --git a/plugins/3d/vrml/x3d.cpp b/plugins/3d/vrml/x3d.cpp
index 77f6f5ab5..c6014d81a 100644
--- a/plugins/3d/vrml/x3d.cpp
+++ b/plugins/3d/vrml/x3d.cpp
@@ -111,7 +111,7 @@ bool X3DPARSER::getGroupingNodes( wxXmlNode* aNode, std::vector<wxXmlNode*>& aRe
          child != NULL;
          child = child->GetNext() )
     {
-        wxString name = child->GetName();
+        const wxString& name = child->GetName();
 
         if( name == "Transform" || name == "Switch" || name == "Group" )
             aResult.push_back( child );
diff --git a/plugins/3d/vrml/x3d/x3d_appearance.cpp b/plugins/3d/vrml/x3d/x3d_appearance.cpp
index 876e49f93..35089f798 100644
--- a/plugins/3d/vrml/x3d/x3d_appearance.cpp
+++ b/plugins/3d/vrml/x3d/x3d_appearance.cpp
@@ -110,7 +110,7 @@ void X3DAPP::readFields( wxXmlNode* aNode )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "DEF" )
         {
@@ -163,7 +163,7 @@ bool X3DAPP::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "DEF" )
         {
diff --git a/plugins/3d/vrml/x3d/x3d_coords.cpp b/plugins/3d/vrml/x3d/x3d_coords.cpp
index 51fe3ba0a..ed67c9eb6 100644
--- a/plugins/3d/vrml/x3d/x3d_coords.cpp
+++ b/plugins/3d/vrml/x3d/x3d_coords.cpp
@@ -78,7 +78,7 @@ bool X3DCOORDS::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "DEF" )
         {
diff --git a/plugins/3d/vrml/x3d/x3d_ifaceset.cpp b/plugins/3d/vrml/x3d/x3d_ifaceset.cpp
index 051b96180..78d5cbee9 100644
--- a/plugins/3d/vrml/x3d/x3d_ifaceset.cpp
+++ b/plugins/3d/vrml/x3d/x3d_ifaceset.cpp
@@ -100,7 +100,7 @@ void X3DIFACESET::readFields( wxXmlNode* aNode )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "DEF" )
         {
diff --git a/plugins/3d/vrml/x3d/x3d_ops.cpp b/plugins/3d/vrml/x3d/x3d_ops.cpp
index 4ce5c8c26..0a413dc00 100644
--- a/plugins/3d/vrml/x3d/x3d_ops.cpp
+++ b/plugins/3d/vrml/x3d/x3d_ops.cpp
@@ -42,7 +42,7 @@ bool X3D::ReadTransform( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "USE" )
         {
@@ -89,7 +89,7 @@ bool X3D::ReadShape( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "USE" )
         {
@@ -129,7 +129,7 @@ bool X3D::ReadAppearance( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "USE" )
         {
@@ -169,7 +169,7 @@ bool X3D::ReadIndexedFaceSet( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDic
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "USE" )
         {
@@ -209,7 +209,7 @@ bool X3D::ReadCoordinates( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "USE" )
         {
diff --git a/plugins/3d/vrml/x3d/x3d_shape.cpp b/plugins/3d/vrml/x3d/x3d_shape.cpp
index e71c7f4b4..93d07f980 100644
--- a/plugins/3d/vrml/x3d/x3d_shape.cpp
+++ b/plugins/3d/vrml/x3d/x3d_shape.cpp
@@ -93,7 +93,7 @@ bool X3DSHAPE::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "DEF" )
         {
diff --git a/plugins/3d/vrml/x3d/x3d_transform.cpp b/plugins/3d/vrml/x3d/x3d_transform.cpp
index 210834958..262db573f 100644
--- a/plugins/3d/vrml/x3d/x3d_transform.cpp
+++ b/plugins/3d/vrml/x3d/x3d_transform.cpp
@@ -121,7 +121,7 @@ void X3DTRANSFORM::readFields( wxXmlNode* aNode )
          prop != NULL;
          prop = prop->GetNext() )
     {
-        wxString pname = prop->GetName();
+        const wxString& pname = prop->GetName();
 
         if( pname == "DEF" )
         {

--------------2.13.5--


From bc44b03f17cd3a0cff598baf4852862f8e72463f Mon Sep 17 00:00:00 2001
From: Camille <camille019@xxxxxxxxxxx>
Date: Sun, 24 Sep 2017 13:06:10 +0200
Subject: [PATCH 3/4] Fix type promotion in math function
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.13.5"

This is a multi-part message in MIME format.
--------------2.13.5
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 .../3d_render_raytracing/PerlinNoise.cpp            | 21 +++++++++++----------
 3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp |  8 +++++---
 2 files changed, 16 insertions(+), 13 deletions(-)


--------------2.13.5
Content-Type: text/x-patch; name="0003-Fix-type-promotion-in-math-function.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0003-Fix-type-promotion-in-math-function.patch"

diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/PerlinNoise.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/PerlinNoise.cpp
index daf4fd321..523edb619 100644
--- a/3d-viewer/3d_rendering/3d_render_raytracing/PerlinNoise.cpp
+++ b/3d-viewer/3d_rendering/3d_render_raytracing/PerlinNoise.cpp
@@ -40,6 +40,7 @@
  */
 
 #include "PerlinNoise.h"
+#include <cmath>
 #include <iostream>
 #include <cmath>
 #include <random>
@@ -97,14 +98,14 @@ PerlinNoise::PerlinNoise( unsigned int seed )
 float PerlinNoise::noise( float x, float y, float z ) const
 {
     // Find the unit cube that contains the point
-    int X = (int) ((float)floor( x )) & 255;
-    int Y = (int) ((float)floor( y )) & 255;
-    int Z = (int) ((float)floor( z )) & 255;
+    int X = static_cast<int>( std::floor( x ) ) & 255;
+    int Y = static_cast<int>( std::floor( y ) ) & 255;
+    int Z = static_cast<int>( std::floor( z ) ) & 255;
 
     // Find relative x, y,z of point in cube
-    x -= (float)floor( x );
-    y -= (float)floor( y );
-    z -= (float)floor( z );
+    x -= std::floor( x );
+    y -= std::floor( y );
+    z -= std::floor( z );
 
     // Compute fade curves for each of x, y, z
     const float u = fade( x );
@@ -143,12 +144,12 @@ float PerlinNoise::noise( float x, float y, float z ) const
 float PerlinNoise::noise( float x, float y ) const
 {
     // Find the unit cube that contains the point
-    int X = (int) ((float)floor( x )) & 255;
-    int Y = (int) ((float)floor( y )) & 255;
+    int X = static_cast<int>( std::floor( x ) ) & 255;
+    int Y = static_cast<int>( std::floor( y ) ) & 255;
 
     // Find relative x, y,z of point in cube
-    x -= (float)floor( x );
-    y -= (float)floor( y );
+    x -= std::floor( x );
+    y -= std::floor( y );
 
     // Compute fade curves for each of x, y
     const float u = fade( x );
diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp
index 5a7104171..6f556b992 100644
--- a/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp
+++ b/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp
@@ -33,6 +33,8 @@
 #include <stdio.h>
 #include <wx/debug.h>
 
+#include <cmath>
+
 //static unsigned int gs_next_rayID = 0;
 
 void RAY::Init( const SFVEC3F& o, const SFVEC3F& d )
@@ -185,7 +187,7 @@ bool IntersectSegment( const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA,
                 aEnd_minus_startB.y - aEnd_minus_startA.y *
                 aEnd_minus_startB.x;
 
-    if( fabs(rxs) >  glm::epsilon<float>() )
+    if( std::abs(rxs) >  glm::epsilon<float>() )
     {
         float inv_rxs = 1.0f / rxs;
 
@@ -294,7 +296,7 @@ bool RAYSEG2D::IntersectSegment( const SFVEC2F &aStart,
                 aEnd_minus_start.y - m_End_minus_start.y *
             aEnd_minus_start.x;
 
-    if( fabs( rxs ) >  glm::epsilon<float>() )
+    if( std::abs( rxs ) >  glm::epsilon<float>() )
     {
         const float inv_rxs = 1.0f / rxs;
 
@@ -371,7 +373,7 @@ bool RAYSEG2D::IntersectCircle( const SFVEC2F &aCenter,
 
     // Otherwise check and make sure that the intersections occur on the ray (t
     // > 0) and return the closer one
-    const float discriminant = sqrt( discriminantsqr );
+    const float discriminant = std::sqrt( discriminantsqr );
     const float t1 = (-qd - discriminant);
     const float t2 = (-qd + discriminant);
 

--------------2.13.5--



References