@@ -163,41 +163,35 @@ private PointF TransformPoint(PointF point)
163163 /// <param name="contained">Indicates whether the stroked contour is fully contained within the interest.</param>
164164 private void ProcessContour ( ReadOnlySpan < PointF > contourPoints , bool isClosed , bool contained )
165165 {
166- StrokeContourSegment [ ] rentedSegments = ArrayPool < StrokeContourSegment > . Shared . Rent ( contourPoints . Length ) ;
167- try
166+ using IMemoryOwner < StrokeContourSegment > rentedSegmentsOwner = this . Allocator . Allocate < StrokeContourSegment > ( contourPoints . Length ) ;
167+ Span < StrokeContourSegment > rentedSegments = rentedSegmentsOwner . Memory . Span ;
168+ int segmentCount = this . BuildContourSegments (
169+ contourPoints ,
170+ isClosed ,
171+ rentedSegments ,
172+ out int distinctPointCount ,
173+ out PointF pointLike ) ;
174+
175+ if ( segmentCount == 0 )
168176 {
169- int segmentCount = this . BuildContourSegments (
170- contourPoints ,
171- isClosed ,
172- rentedSegments ,
173- out int distinctPointCount ,
174- out PointF pointLike ) ;
175-
176- if ( segmentCount == 0 )
177- {
178- this . EmitPointStrokeContour ( pointLike , contained ) ;
179- return ;
180- }
181-
182- if ( segmentCount == 1 || distinctPointCount == 2 )
183- {
184- StrokeContourSegment segment = rentedSegments [ 0 ] ;
185- this . EmitOpenSegmentStrokeContour ( segment . Start , segment . End , contained ) ;
186- return ;
187- }
188-
189- if ( isClosed )
190- {
191- this . EmitClosedStrokeContour ( rentedSegments . AsSpan ( 0 , segmentCount ) , contained ) ;
192- return ;
193- }
177+ this . EmitPointStrokeContour ( pointLike , contained ) ;
178+ return ;
179+ }
194180
195- this . EmitOpenStrokeContour ( rentedSegments . AsSpan ( 0 , segmentCount ) , contained ) ;
181+ if ( segmentCount == 1 || distinctPointCount == 2 )
182+ {
183+ StrokeContourSegment segment = rentedSegments [ 0 ] ;
184+ this . EmitOpenSegmentStrokeContour ( segment . Start , segment . End , contained ) ;
185+ return ;
196186 }
197- finally
187+
188+ if ( isClosed )
198189 {
199- ArrayPool < StrokeContourSegment > . Shared . Return ( rentedSegments ) ;
190+ this . EmitClosedStrokeContour ( rentedSegments [ ..segmentCount ] , contained ) ;
191+ return ;
200192 }
193+
194+ this . EmitOpenStrokeContour ( rentedSegments [ ..segmentCount ] , contained ) ;
201195 }
202196
203197 /// <summary>
0 commit comments