From 73f835437e742601a03d3b2e38fdf1dab3eb6dc6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 19 Mar 2022 10:40:55 +0000 Subject: [PATCH] Don't modify outer loop variable inside inner loop. --- pcbnew/footprint.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index f55eab7810..0ffdd4434d 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -2274,27 +2274,29 @@ void FOOTPRINT::CheckOverlappingPads( const std::functionSameLogicalPadAs( other ) ) continue; - // store canonical order so we don't collide in both directions - // (a:b and b:a) - if( static_cast( pad ) > static_cast( other ) ) - std::swap( pad, other ); + // store canonical order so we don't collide in both directions (a:b and b:a) + PAD* a = pad; + PAD* b = other; - if( checkedPairs.count( { pad, other } ) ) + if( static_cast( a ) > static_cast( b ) ) + std::swap( a, b ); + + if( checkedPairs.count( { a, b } ) ) { continue; } else { - checkedPairs[ { pad, other } ] = 1; - } + checkedPairs[ { a, b } ] = 1; - VECTOR2I pos; - SHAPE* padShape = pad->GetEffectiveShape().get(); - SHAPE* otherShape = other->GetEffectiveShape().get(); + VECTOR2I pos; + SHAPE* padShape = pad->GetEffectiveShape().get(); + SHAPE* otherShape = other->GetEffectiveShape().get(); - if( padShape->Collide( otherShape, 0, nullptr, &pos ) ) - { - (aErrorHandler)( pad, other, pos ); + if( padShape->Collide( otherShape, 0, nullptr, &pos ) ) + { + (aErrorHandler)( pad, other, pos ); + } } } }