Browse Source

Avoid copies when using auto

pcb_db
Ian McInerney 11 months ago
parent
commit
c0622eaa45
  1. 3
      3d-viewer/3d_canvas/board_adapter.cpp
  2. 2
      common/widgets/listbox_tricks.cpp
  3. 2
      include/http_lib/http_lib_connection.h
  4. 3
      pcbnew/exporters/exporter_vrml.cpp
  5. 4
      pcbnew/generators/pcb_tuning_pattern.cpp
  6. 2
      pcbnew/router/pns_multi_dragger.cpp

3
3d-viewer/3d_canvas/board_adapter.cpp

@ -639,8 +639,9 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
// Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables
auto findColor =
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
{
if( aColorName.StartsWith( wxT( "#" ) ) )
{

2
common/widgets/listbox_tricks.cpp

@ -215,7 +215,7 @@ void LISTBOX_TRICKS::OnListBoxRDown( wxMouseEvent& aEvent )
{
wxMenu menu;
const auto mstr = [&]( const MENU_ID& id )
const auto mstr = [&]( const MENU_ID& id ) -> const wxString&
{
return m_menuStrings[id];
};

2
include/http_lib/http_lib_connection.h

@ -65,7 +65,7 @@ public:
return m_categoryDescriptions.at( aCategoryName );
}
auto getCachedParts() { return m_cache; }
auto& getCachedParts() { return m_cache; }
private:
// This is clunky but at the moment the only way to free the pointer after use without KiCad crashing.

3
pcbnew/exporters/exporter_vrml.cpp

@ -131,8 +131,9 @@ EXPORTER_PCB_VRML::EXPORTER_PCB_VRML( BOARD* aBoard ) :
const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
// Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables
auto findColor =
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
{
if( aColorName.StartsWith( wxT( "#" ) ) )
{

4
pcbnew/generators/pcb_tuning_pattern.cpp

@ -2282,8 +2282,8 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent )
auto applyCommonSettings = [&]( PCB_TUNING_PATTERN* aPattern )
{
auto origTargetLength = aPattern->GetSettings().m_targetLength;
auto origTargetSkew = aPattern->GetSettings().m_targetSkew;
const auto& origTargetLength = aPattern->GetSettings().m_targetLength;
const auto& origTargetSkew = aPattern->GetSettings().m_targetSkew;
aPattern->GetSettings() = meanderSettings;

2
pcbnew/router/pns_multi_dragger.cpp

@ -557,7 +557,7 @@ bool MULTI_DRAGGER::multidragMarkObstacles( std::vector<MDRAG_LINE>& aCompletedL
{
for( int l2 = l1 + 1; l2 < aCompletedLines.size(); l2++ )
{
auto l1l = aCompletedLines[l1].draggedLine;
const auto& l1l = aCompletedLines[l1].draggedLine;
auto l2l = aCompletedLines[l2].draggedLine;
if( clipToOtherLine( m_lastNode, l1l, l2l ) )

Loading…
Cancel
Save