Skip to content

Commit d3ec07c

Browse files
committed
Improve copying in ClipperOffset
1 parent 9b91ee4 commit d3ec07c

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/ImageSharp.Drawing/Shapes/PolygonClipper/ClipperOffset.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ public ComplexPolygon Execute(float width)
3232
for (int i = 0; i < solution.Count; i++)
3333
{
3434
PathF pt = solution[i];
35-
PointF[] points = new PointF[pt.Count];
36-
for (int j = 0; j < pt.Count; j++)
37-
{
38-
points[j] = pt[j];
39-
}
35+
PointF[] points = pt.ToArray();
4036

4137
polygons[i] = new Polygon(points);
4238
}
@@ -53,10 +49,7 @@ public ComplexPolygon Execute(float width)
5349
public void AddPath(ReadOnlySpan<PointF> pathPoints, JointStyle jointStyle, EndCapStyle endCapStyle)
5450
{
5551
PathF points = new(pathPoints.Length);
56-
for (int i = 0; i < pathPoints.Length; i++)
57-
{
58-
points.Add(pathPoints[i]);
59-
}
52+
points.AddRange(pathPoints);
6053

6154
this.polygonClipperOffset.AddPath(points, jointStyle, endCapStyle);
6255
}

src/ImageSharp.Drawing/Shapes/PolygonClipper/PolygonOffsetter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ private class Group
643643
{
644644
public Group(PathsF paths, JointStyle joinType, EndCapStyle endType = EndCapStyle.Polygon)
645645
{
646-
this.InPaths = new PathsF(paths);
646+
this.InPaths = paths;
647647
this.JoinType = joinType;
648648
this.EndType = endType;
649649
this.OutPath = new PathF();

0 commit comments

Comments
 (0)