Skip to content

Commit 4117466

Browse files
Cache flattening properly.
1 parent 04b6c65 commit 4117466

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/ImageSharp.Drawing/Processing/DrawingCanvas.PreFlattenedPath.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ private sealed class FlattenedPath : IPath, ISimplePath
2020
private readonly PointF[] points;
2121
private readonly bool isClosed;
2222
private RectangleF bounds;
23+
private ISimplePath[]? flattenResult;
2324

2425
public FlattenedPath(PointF[] points, bool isClosed, RectangleF bounds)
2526
{
@@ -41,10 +42,7 @@ public FlattenedPath(PointF[] points, bool isClosed, RectangleF bounds)
4142
ReadOnlyMemory<PointF> ISimplePath.Points => this.points;
4243

4344
/// <inheritdoc />
44-
public IEnumerable<ISimplePath> Flatten()
45-
{
46-
yield return this;
47-
}
45+
public IEnumerable<ISimplePath> Flatten() => this.flattenResult ??= [this];
4846

4947
/// <summary>
5048
/// Transforms all points in place and updates the bounds.

0 commit comments

Comments
 (0)