Don't modify outer loop variable inside inner loop.

This commit is contained in:
Jeff Young 2022-03-19 10:40:55 +00:00
parent 476f1a7d4d
commit 73f835437e
1 changed files with 15 additions and 13 deletions

View File

@ -2274,27 +2274,29 @@ void FOOTPRINT::CheckOverlappingPads( const std::function<void( const PAD*, cons
if( other == pad || pad->SameLogicalPadAs( other ) ) if( other == pad || pad->SameLogicalPadAs( other ) )
continue; continue;
// store canonical order so we don't collide in both directions // store canonical order so we don't collide in both directions (a:b and b:a)
// (a:b and b:a) PAD* a = pad;
if( static_cast<void*>( pad ) > static_cast<void*>( other ) ) PAD* b = other;
std::swap( pad, other );
if( checkedPairs.count( { pad, other } ) ) if( static_cast<void*>( a ) > static_cast<void*>( b ) )
std::swap( a, b );
if( checkedPairs.count( { a, b } ) )
{ {
continue; continue;
} }
else else
{ {
checkedPairs[ { pad, other } ] = 1; checkedPairs[ { a, b } ] = 1;
}
VECTOR2I pos; VECTOR2I pos;
SHAPE* padShape = pad->GetEffectiveShape().get(); SHAPE* padShape = pad->GetEffectiveShape().get();
SHAPE* otherShape = other->GetEffectiveShape().get(); SHAPE* otherShape = other->GetEffectiveShape().get();
if( padShape->Collide( otherShape, 0, nullptr, &pos ) ) if( padShape->Collide( otherShape, 0, nullptr, &pos ) )
{ {
(aErrorHandler)( pad, other, pos ); (aErrorHandler)( pad, other, pos );
}
} }
} }
} }