From 98e760da9332b20ffe3d5c757cff344f9f32f122 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 9 Sep 2022 10:55:35 +0100 Subject: [PATCH] Coverity-suggested improvements. --- pcbnew/tools/edit_tool.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 512868435e..673d20bdc9 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -308,18 +308,28 @@ int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent ) if( aCollector.GetCount() > 1 ) sTool->GuessSelectionCandidates( aCollector, aPt ); - // If we have a knee between two segments, or a via attached to two segments, - // then drop the selection to a single item. - std::initializer_list trackTypes = { PCB_TRACE_T, PCB_ARC_T }; - std::vector tracks; - std::vector vias; + /* + * If we have a knee between two segments, or a via attached to two segments, + * then drop the selection to a single item. + */ + + std::vector tracks; + std::vector vias; for( EDA_ITEM* item : aCollector ) { - if( item->IsType( trackTypes ) ) + switch( item->Type() ) + { + case PCB_TRACE_T: + case PCB_ARC_T: tracks.push_back( static_cast( item ) ); - else if( item->Type() == PCB_VIA_T ) + break; + case PCB_VIA_T: vias.push_back( static_cast( item ) ); + break; + default: + break; + } } if( tracks.size() == 2 ) @@ -330,7 +340,8 @@ int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent ) if( vias.size() == 1 ) { - cItems = c->GetConnectedItemsAtAnchor( vias[0], aPt, trackTypes, + cItems = c->GetConnectedItemsAtAnchor( vias[0], aPt, + { PCB_TRACE_T, PCB_ARC_T }, vias[0]->GetWidth() / 2 ); if( alg::contains( cItems, tracks[0] ) @@ -342,7 +353,8 @@ int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent ) } else if( vias.size() == 0 ) { - cItems = c->GetConnectedItemsAtAnchor( tracks[0], aPt, trackTypes, + cItems = c->GetConnectedItemsAtAnchor( tracks[0], aPt, + { PCB_TRACE_T, PCB_ARC_T }, tracks[0]->GetWidth() / 2 ); if( alg::contains( cItems, tracks[1] ) )