|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
3 | 3 |
|
| 4 | +using System.Runtime.CompilerServices; |
4 | 5 | using SixLabors.PolygonClipper; |
5 | 6 | using ClipperPolygon = SixLabors.PolygonClipper.Polygon; |
6 | 7 |
|
@@ -100,6 +101,7 @@ public static ClipperPolygon FromSimplePaths(IEnumerable<ISimplePath> paths, Int |
100 | 101 | } |
101 | 102 |
|
102 | 103 | // Parent assignment: pick the smallest-area ring that contains the bottom-left vertex. |
| 104 | + // TODO: We can use pooling here if we care about large numbers of rings. |
103 | 105 | int[] parent = new int[m]; |
104 | 106 | Array.Fill(parent, -1); |
105 | 107 |
|
@@ -131,6 +133,7 @@ public static ClipperPolygon FromSimplePaths(IEnumerable<ISimplePath> paths, Int |
131 | 133 | } |
132 | 134 |
|
133 | 135 | // Depth = number of ancestors by following Parent links. |
| 136 | + // TODO: We can pool this if we care about large numbers of rings. |
134 | 137 | int[] depth = new int[m]; |
135 | 138 | for (int i = 0; i < m; i++) |
136 | 139 | { |
@@ -350,9 +353,6 @@ private static bool PointInPolygonNonZero(in Vertex p, List<Vertex> ring) |
350 | 353 | /// </code> |
351 | 354 | /// Left if cross > 0, right if cross < 0, collinear if cross == 0. |
352 | 355 | /// </remarks> |
353 | | - private static bool IsLeft(Vertex a, Vertex b, Vertex p) |
354 | | - { |
355 | | - double cross = ((b.X - a.X) * (p.Y - a.Y)) - ((b.Y - a.Y) * (p.X - a.X)); |
356 | | - return cross > 0d; |
357 | | - } |
| 356 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 357 | + private static bool IsLeft(Vertex a, Vertex b, Vertex p) => Vertex.Cross(b - a, p - a) > 0d; |
358 | 358 | } |
0 commit comments