From 5b438d63987ba1fa6f13389b07f2c4013a64d5c3 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sun, 20 Aug 2023 14:29:02 +0300 Subject: [PATCH] Optimize makeEffectiveShapes for polygons. --- common/eda_shape.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 39ab431b26..063c80b67c 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -1221,18 +1221,20 @@ std::vector EDA_SHAPE::makeEffectiveShapes( bool aEdgeOnly, bool aLineCh for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii ) { - SHAPE_LINE_CHAIN l = GetPolyShape().COutline( ii ); - - if( aLineChainOnly ) - l.SetClosed( false ); + const SHAPE_LINE_CHAIN& l = GetPolyShape().COutline( ii ); if( IsFilled() && !aEdgeOnly ) effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) ); if( width > 0 || !IsFilled() || aEdgeOnly ) { - for( int jj = 0; jj < l.SegmentCount(); jj++ ) - effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( jj ), width ) ); + int segCount = l.SegmentCount(); + + if( aLineChainOnly && l.IsClosed() ) + segCount--; // Treat closed chain as open + + for( int jj = 0; jj < segCount; jj++ ) + effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.CSegment( jj ), width ) ); } } }