|
4 | 4 | using System.Buffers; |
5 | 5 | using System.Numerics; |
6 | 6 | using System.Runtime.CompilerServices; |
| 7 | +using System.Runtime.InteropServices; |
7 | 8 | using SixLabors.ImageSharp.Memory; |
8 | 9 |
|
9 | 10 | namespace SixLabors.ImageSharp.Drawing; |
@@ -61,7 +62,7 @@ internal InternalPath(ILineSegment segment, bool isClosedPath) |
61 | 62 | /// <param name="points">The points.</param> |
62 | 63 | /// <param name="isClosedPath">if set to <c>true</c> [is closed path].</param> |
63 | 64 | internal InternalPath(ReadOnlyMemory<PointF> points, bool isClosedPath) |
64 | | - : this(Simplify(points, isClosedPath, true), isClosedPath) |
| 65 | + : this(Simplify(points.Span, isClosedPath, true), isClosedPath) |
65 | 66 | { |
66 | 67 | } |
67 | 68 |
|
@@ -247,16 +248,14 @@ private static PointData[] Simplify(IReadOnlyList<ILineSegment> segments, bool i |
247 | 248 | foreach (ILineSegment seg in segments) |
248 | 249 | { |
249 | 250 | ReadOnlyMemory<PointF> points = seg.Flatten(); |
250 | | - simplified.AddRange(points.ToArray()); |
| 251 | + simplified.AddRange(points.Span); |
251 | 252 | } |
252 | 253 |
|
253 | | - return Simplify(simplified.ToArray(), isClosed, removeCloseAndCollinear); |
| 254 | + return Simplify(CollectionsMarshal.AsSpan(simplified), isClosed, removeCloseAndCollinear); |
254 | 255 | } |
255 | 256 |
|
256 | | - private static PointData[] Simplify(ReadOnlyMemory<PointF> vectors, bool isClosed, bool removeCloseAndCollinear) |
| 257 | + private static PointData[] Simplify(ReadOnlySpan<PointF> points, bool isClosed, bool removeCloseAndCollinear) |
257 | 258 | { |
258 | | - ReadOnlySpan<PointF> points = vectors.Span; |
259 | | - |
260 | 259 | int polyCorners = points.Length; |
261 | 260 | if (polyCorners == 0) |
262 | 261 | { |
|
0 commit comments