Clean up some auto usage
Don't make new copies of shared_ptr if we can use references. Keep auto usage down to hard-to-type-out sequences
This commit is contained in:
parent
db91bcbabf
commit
35ac39844f
|
@ -174,7 +174,7 @@ int LIB_ID::HasIllegalChars( const UTF8& aLibItemName )
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
for( auto ch : aLibItemName )
|
for( auto& ch : aLibItemName )
|
||||||
{
|
{
|
||||||
if( !isLegalChar( ch ) )
|
if( !isLegalChar( ch ) )
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
@ -62,7 +62,7 @@ wxString formatWildcardExt( const wxString& aWildcard )
|
||||||
wxString wc;
|
wxString wc;
|
||||||
#if defined( __WXGTK__ )
|
#if defined( __WXGTK__ )
|
||||||
|
|
||||||
for( auto ch : aWildcard )
|
for( auto& ch : aWildcard )
|
||||||
{
|
{
|
||||||
if( wxIsalpha( ch ) )
|
if( wxIsalpha( ch ) )
|
||||||
wc += wxString::Format( "[%c%c]", wxTolower( ch ), wxToupper( ch ) );
|
wc += wxString::Format( "[%c%c]", wxTolower( ch ), wxToupper( ch ) );
|
||||||
|
|
|
@ -244,7 +244,7 @@ void SCH_LEGACY_PLUGIN::loadHierarchy( SCH_SHEET* aSheet )
|
||||||
aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
|
aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
|
||||||
aSheet->GetScreen()->SetFileExists( true );
|
aSheet->GetScreen()->SetFileExists( true );
|
||||||
|
|
||||||
for( auto aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
|
for( SCH_ITEM* aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
|
||||||
{
|
{
|
||||||
wxCHECK2( aItem->Type() == SCH_SHEET_T, continue );
|
wxCHECK2( aItem->Type() == SCH_SHEET_T, continue );
|
||||||
auto sheet = static_cast<SCH_SHEET*>( aItem );
|
auto sheet = static_cast<SCH_SHEET*>( aItem );
|
||||||
|
@ -1466,7 +1466,7 @@ void SCH_LEGACY_PLUGIN::Format( SCH_SHEET* aSheet )
|
||||||
auto cmp = []( const SCH_ITEM* a, const SCH_ITEM* b ) { return *a < *b; };
|
auto cmp = []( const SCH_ITEM* a, const SCH_ITEM* b ) { return *a < *b; };
|
||||||
std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
|
std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
|
||||||
|
|
||||||
for( auto item : screen->Items() )
|
for( SCH_ITEM* item : screen->Items() )
|
||||||
save_map.insert( item );
|
save_map.insert( item );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,7 @@ NGSPICE::NGSPICE() :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NGSPICE::~NGSPICE()
|
NGSPICE::~NGSPICE() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NGSPICE::Init( const SPICE_SIMULATOR_SETTINGS* aSettings )
|
void NGSPICE::Init( const SPICE_SIMULATOR_SETTINGS* aSettings )
|
||||||
|
@ -595,7 +593,7 @@ bool NGSPICE::loadSpinit( const string& aFileName )
|
||||||
if( !file.Open( aFileName ) )
|
if( !file.Open( aFileName ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for( auto cmd = file.GetFirstLine(); !file.Eof(); cmd = file.GetNextLine() )
|
for( wxString& cmd = file.GetFirstLine(); !file.Eof(); cmd = file.GetNextLine() )
|
||||||
Command( cmd.ToStdString() );
|
Command( cmd.ToStdString() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr<SYMBOL_BUFF
|
||||||
aSymbolBuf->SetOriginal( new LIB_SYMBOL( *libSymbol ) );
|
aSymbolBuf->SetOriginal( new LIB_SYMBOL( *libSymbol ) );
|
||||||
|
|
||||||
// Save the derived symbols.
|
// Save the derived symbols.
|
||||||
for( auto entry : derivedSymbols )
|
for( const wxString& entry : derivedSymbols )
|
||||||
{
|
{
|
||||||
std::shared_ptr<SYMBOL_BUFFER> symbol = GetBuffer( entry );
|
std::shared_ptr<SYMBOL_BUFFER> symbol = GetBuffer( entry );
|
||||||
|
|
||||||
|
@ -1241,7 +1241,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr<SYMBOL_BUFF
|
||||||
std::shared_ptr<SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER>
|
std::shared_ptr<SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER>
|
||||||
SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const
|
SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const
|
||||||
{
|
{
|
||||||
for( auto entry : m_symbols )
|
for( std::shared_ptr<SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER> entry : m_symbols )
|
||||||
{
|
{
|
||||||
if( entry->GetSymbol()->GetName() == aAlias )
|
if( entry->GetSymbol()->GetName() == aAlias )
|
||||||
return entry;
|
return entry;
|
||||||
|
@ -1253,7 +1253,7 @@ SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const
|
||||||
|
|
||||||
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::HasDerivedSymbols( const wxString& aParentName ) const
|
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::HasDerivedSymbols( const wxString& aParentName ) const
|
||||||
{
|
{
|
||||||
for( auto entry : m_symbols )
|
for( auto& entry : m_symbols )
|
||||||
{
|
{
|
||||||
if( entry->GetSymbol()->IsAlias() )
|
if( entry->GetSymbol()->IsAlias() )
|
||||||
{
|
{
|
||||||
|
@ -1288,7 +1288,7 @@ size_t SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetDerivedSymbolNames( const wxString
|
||||||
{
|
{
|
||||||
wxCHECK( !aSymbolName.IsEmpty(), 0 );
|
wxCHECK( !aSymbolName.IsEmpty(), 0 );
|
||||||
|
|
||||||
for( auto entry : m_symbols )
|
for( auto& entry : m_symbols )
|
||||||
{
|
{
|
||||||
if( entry->GetSymbol()->IsAlias() )
|
if( entry->GetSymbol()->IsAlias() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -584,7 +584,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Update our cache of the connected items.
|
// Update our cache of the connected items.
|
||||||
|
|
||||||
// First, re-attach our drag labels to the original line being re-merged.
|
// First, re-attach our drag labels to the original line being re-merged.
|
||||||
for( auto possibleLabel : m_lineConnectionCache[bendLine] )
|
for( EDA_ITEM* possibleLabel : m_lineConnectionCache[bendLine] )
|
||||||
{
|
{
|
||||||
switch( possibleLabel->Type() )
|
switch( possibleLabel->Type() )
|
||||||
{
|
{
|
||||||
|
@ -684,7 +684,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// Update our cache of the connected items.
|
// Update our cache of the connected items.
|
||||||
// First, attach our drag labels to the line left behind.
|
// First, attach our drag labels to the line left behind.
|
||||||
for( auto possibleLabel : m_lineConnectionCache[line] )
|
for( EDA_ITEM* possibleLabel : m_lineConnectionCache[line] )
|
||||||
{
|
{
|
||||||
switch( possibleLabel->Type() )
|
switch( possibleLabel->Type() )
|
||||||
{
|
{
|
||||||
|
@ -1588,7 +1588,7 @@ void SCH_MOVE_TOOL::setTransitions()
|
||||||
|
|
||||||
void SCH_MOVE_TOOL::commitDragLines()
|
void SCH_MOVE_TOOL::commitDragLines()
|
||||||
{
|
{
|
||||||
for( auto newLine : m_newDragLines )
|
for( SCH_LINE* newLine : m_newDragLines )
|
||||||
{
|
{
|
||||||
newLine->ClearEditFlags();
|
newLine->ClearEditFlags();
|
||||||
saveCopyInUndoList( newLine, UNDO_REDO::NEWITEM, true );
|
saveCopyInUndoList( newLine, UNDO_REDO::NEWITEM, true );
|
||||||
|
@ -1596,7 +1596,7 @@ void SCH_MOVE_TOOL::commitDragLines()
|
||||||
|
|
||||||
// These lines have been changed, but aren't selected. We need
|
// These lines have been changed, but aren't selected. We need
|
||||||
// to manually clear these edit flags or they'll stick around.
|
// to manually clear these edit flags or they'll stick around.
|
||||||
for( auto oldLine : m_changedDragLines )
|
for( SCH_LINE* oldLine : m_changedDragLines )
|
||||||
{
|
{
|
||||||
oldLine->ClearEditFlags();
|
oldLine->ClearEditFlags();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
|
||||||
// (maybe convert geometry into positives?)
|
// (maybe convert geometry into positives?)
|
||||||
}
|
}
|
||||||
|
|
||||||
for( auto item : gerber->GetItems() )
|
for( GERBER_DRAW_ITEM* item : gerber->GetItems() )
|
||||||
GetCanvas()->GetView()->Add( (KIGFX::VIEW_ITEM*) item );
|
GetCanvas()->GetView()->Add( (KIGFX::VIEW_ITEM*) item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -824,11 +824,11 @@ const std::vector<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetConnectedItemsAtA
|
||||||
std::vector<BOARD_CONNECTED_ITEM*> rv;
|
std::vector<BOARD_CONNECTED_ITEM*> rv;
|
||||||
SEG::ecoord maxErrorSq = (SEG::ecoord) aMaxError * aMaxError;
|
SEG::ecoord maxErrorSq = (SEG::ecoord) aMaxError * aMaxError;
|
||||||
|
|
||||||
for( auto cnItem : entry.GetItems() )
|
for( CN_ITEM* cnItem : entry.GetItems() )
|
||||||
{
|
{
|
||||||
for( auto connected : cnItem->ConnectedItems() )
|
for( CN_ITEM* connected : cnItem->ConnectedItems() )
|
||||||
{
|
{
|
||||||
for( auto anchor : connected->Anchors() )
|
for( std::shared_ptr<CN_ANCHOR>& anchor : connected->Anchors() )
|
||||||
{
|
{
|
||||||
if( ( anchor->Pos() - aAnchor ).SquaredEuclideanNorm() <= maxErrorSq )
|
if( ( anchor->Pos() - aAnchor ).SquaredEuclideanNorm() <= maxErrorSq )
|
||||||
{
|
{
|
||||||
|
@ -995,7 +995,7 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForComponent( FOOTPRINT
|
||||||
std::set<const PAD*> pads;
|
std::set<const PAD*> pads;
|
||||||
std::vector<CN_EDGE> edges;
|
std::vector<CN_EDGE> edges;
|
||||||
|
|
||||||
for( auto pad : aComponent->Pads() )
|
for( PAD* pad : aComponent->Pads() )
|
||||||
{
|
{
|
||||||
nets.insert( pad->GetNetCode() );
|
nets.insert( pad->GetNetCode() );
|
||||||
pads.insert( pad );
|
pads.insert( pad );
|
||||||
|
|
|
@ -387,7 +387,7 @@ bool CN_CLUSTER::Contains( const BOARD_CONNECTED_ITEM* aItem )
|
||||||
|
|
||||||
void CN_CLUSTER::Dump()
|
void CN_CLUSTER::Dump()
|
||||||
{
|
{
|
||||||
for( auto item : m_items )
|
for( CN_ITEM* item : m_items )
|
||||||
{
|
{
|
||||||
wxLogTrace( wxT( "CN" ), wxT( " - item : %p bitem : %p type : %d inet %s\n" ),
|
wxLogTrace( wxT( "CN" ), wxT( " - item : %p bitem : %p type : %d inet %s\n" ),
|
||||||
item,
|
item,
|
||||||
|
|
|
@ -433,7 +433,7 @@ public:
|
||||||
|
|
||||||
void ClearDirtyFlags()
|
void ClearDirtyFlags()
|
||||||
{
|
{
|
||||||
for( auto item : m_items )
|
for( CN_ITEM* item : m_items )
|
||||||
item->SetDirty( false );
|
item->SetDirty( false );
|
||||||
|
|
||||||
SetDirty( false );
|
SetDirty( false );
|
||||||
|
|
|
@ -59,7 +59,7 @@ enum PATH_STATUS {
|
||||||
|
|
||||||
static bool isVertexVisited( CN_ITEM* v, const std::vector<CN_ITEM*>& path )
|
static bool isVertexVisited( CN_ITEM* v, const std::vector<CN_ITEM*>& path )
|
||||||
{
|
{
|
||||||
for( auto u : path )
|
for( CN_ITEM* u : path )
|
||||||
{
|
{
|
||||||
if ( u == v )
|
if ( u == v )
|
||||||
return true;
|
return true;
|
||||||
|
@ -95,11 +95,11 @@ static PATH_STATUS uniquePathBetweenNodes( CN_ITEM* u, CN_ITEM* v, std::vector<C
|
||||||
pathFound = true;
|
pathFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( auto ci : last->ConnectedItems() )
|
for( CN_ITEM* ci : last->ConnectedItems() )
|
||||||
{
|
{
|
||||||
bool vertexVisited = isVertexVisited( ci, path );
|
bool vertexVisited = isVertexVisited( ci, path );
|
||||||
|
|
||||||
for( auto& p : Q )
|
for( std::vector<CN_ITEM*>& p : Q )
|
||||||
if( isVertexVisited( ci, p ) )
|
if( isVertexVisited( ci, p ) )
|
||||||
{
|
{
|
||||||
vertexVisited = true;
|
vertexVisited = true;
|
||||||
|
|
|
@ -725,7 +725,7 @@ LSEQ PANEL_SETUP_LAYERS::getNonRemovableLayers()
|
||||||
PCB_LAYER_COLLECTOR collector;
|
PCB_LAYER_COLLECTOR collector;
|
||||||
LSEQ newLayerSeq = newLayers.Seq();
|
LSEQ newLayerSeq = newLayers.Seq();
|
||||||
|
|
||||||
for( auto layer_id : curLayers.Seq() )
|
for( PCB_LAYER_ID layer_id : curLayers.Seq() )
|
||||||
{
|
{
|
||||||
if( IsCopperLayer( layer_id ) ) // Copper layers are not taken into account here
|
if( IsCopperLayer( layer_id ) ) // Copper layers are not taken into account here
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1723,7 +1723,7 @@ bool DRC_ENGINE::IsNetTie( BOARD_ITEM* aItem )
|
||||||
|
|
||||||
DRC_TEST_PROVIDER* DRC_ENGINE::GetTestProvider( const wxString& name ) const
|
DRC_TEST_PROVIDER* DRC_ENGINE::GetTestProvider( const wxString& name ) const
|
||||||
{
|
{
|
||||||
for( auto prov : m_testProviders )
|
for( DRC_TEST_PROVIDER* prov : m_testProviders )
|
||||||
{
|
{
|
||||||
if( name == prov->GetName() )
|
if( name == prov->GetName() )
|
||||||
return prov;
|
return prov;
|
||||||
|
|
|
@ -391,10 +391,10 @@ FOOTPRINT* FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard( BOARD* aPcb )
|
||||||
|
|
||||||
oldName = fpname;
|
oldName = fpname;
|
||||||
|
|
||||||
for( auto mod : aPcb->Footprints() )
|
for( FOOTPRINT* fp : aPcb->Footprints() )
|
||||||
{
|
{
|
||||||
if( fpname == mod->GetReference() )
|
if( fpname == fp->GetReference() )
|
||||||
return mod;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -359,7 +359,7 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
|
||||||
|
|
||||||
PCB_EDIT_FRAME& editFrame = *getEditFrame<PCB_EDIT_FRAME>();
|
PCB_EDIT_FRAME& editFrame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
|
||||||
auto pt = aInductorPattern.m_End - aInductorPattern.m_Start;
|
wxPoint pt = aInductorPattern.m_End - aInductorPattern.m_Start;
|
||||||
int min_len = KiROUND( EuclideanNorm( pt ) );
|
int min_len = KiROUND( EuclideanNorm( pt ) );
|
||||||
aInductorPattern.m_Length = min_len;
|
aInductorPattern.m_Length = min_len;
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void PCB_GROUP::SetPosition( const VECTOR2I& aNewpos )
|
||||||
|
|
||||||
void PCB_GROUP::SetLayerRecursive( PCB_LAYER_ID aLayer, int aDepth )
|
void PCB_GROUP::SetLayerRecursive( PCB_LAYER_ID aLayer, int aDepth )
|
||||||
{
|
{
|
||||||
for( auto item : m_items )
|
for( BOARD_ITEM* item : m_items )
|
||||||
{
|
{
|
||||||
if( ( item->Type() == PCB_GROUP_T ) && ( aDepth > 0 ) )
|
if( ( item->Type() == PCB_GROUP_T ) && ( aDepth > 0 ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,7 +128,7 @@ bool FABMASTER::Read( const std::string& aFile )
|
||||||
|
|
||||||
bool quoted = false;
|
bool quoted = false;
|
||||||
|
|
||||||
for( auto ch : buffer )
|
for( auto& ch : buffer )
|
||||||
{
|
{
|
||||||
switch( ch )
|
switch( ch )
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,7 +133,7 @@ VECTOR2I PCB_GRID_HELPER::AlignToArc( const VECTOR2I& aPoint, const SHAPE_ARC& a
|
||||||
|
|
||||||
int min_d = std::numeric_limits<int>::max();
|
int min_d = std::numeric_limits<int>::max();
|
||||||
|
|
||||||
for( auto pt : { aArc.GetP0(), aArc.GetP1() } )
|
for( VECTOR2I& pt : { aArc.GetP0(), aArc.GetP1() } )
|
||||||
{
|
{
|
||||||
int d = ( pt - aPoint ).EuclideanNorm();
|
int d = ( pt - aPoint ).EuclideanNorm();
|
||||||
|
|
||||||
|
|
|
@ -661,7 +661,7 @@ bool TRACKS_CLEANER::mergeCollinearSegments( PCB_TRACK* aSeg1, PCB_TRACK* aSeg2
|
||||||
// If the existing connected points are not the same as the points generated by our
|
// If the existing connected points are not the same as the points generated by our
|
||||||
// min/max alg, then assign the missing points to the end closest. This ensures that
|
// min/max alg, then assign the missing points to the end closest. This ensures that
|
||||||
// our replacement track is still connected
|
// our replacement track is still connected
|
||||||
for( auto pt : pts )
|
for( auto& pt : pts )
|
||||||
{
|
{
|
||||||
if( !dummy_seg.IsPointOnEnds( wxPoint( pt.x, pt.y ) ) )
|
if( !dummy_seg.IsPointOnEnds( wxPoint( pt.x, pt.y ) ) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue