Skip to content

Commit 3ca55f6

Browse files
committed
encapsulated to make methed easier to read
1 parent e56721b commit 3ca55f6

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

src/ImageSharp.Drawing/Shapes/ComplexPolygon.cs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,7 @@ public int FindIntersections(PointF start, PointF end, PointF[] buffer, int offs
193193
/// <inheritdoc />
194194
public int FindIntersections(PointF start, PointF end, Span<PointF> buffer, IntersectionRule intersectionRule)
195195
{
196-
if (this.internalPaths == null)
197-
{
198-
lock (this.paths)
199-
{
200-
if (this.internalPaths == null)
201-
{
202-
this.internalPaths = new List<InternalPath>(this.paths.Length);
203-
204-
foreach (var p in this.paths)
205-
{
206-
foreach (var s in p.Flatten())
207-
{
208-
var ip = new InternalPath(s.Points, s.IsClosed);
209-
this.internalPaths.Add(ip);
210-
}
211-
}
212-
}
213-
}
214-
}
196+
this.EnsureInternalPathsInitalized();
215197

216198
int totalAdded = 0;
217199
Orientation[] orientations = ArrayPool<Orientation>.Shared.Rent(buffer.Length); // the largest number of intersections of any sub path of the set is the max size with need for this buffer.
@@ -250,6 +232,29 @@ public int FindIntersections(PointF start, PointF end, Span<PointF> buffer, Inte
250232
return totalAdded;
251233
}
252234

235+
private void EnsureInternalPathsInitalized()
236+
{
237+
if (this.internalPaths == null)
238+
{
239+
lock (this.paths)
240+
{
241+
if (this.internalPaths == null)
242+
{
243+
this.internalPaths = new List<InternalPath>(this.paths.Length);
244+
245+
foreach (var p in this.paths)
246+
{
247+
foreach (var s in p.Flatten())
248+
{
249+
var ip = new InternalPath(s.Points, s.IsClosed);
250+
this.internalPaths.Add(ip);
251+
}
252+
}
253+
}
254+
}
255+
}
256+
}
257+
253258
/// <summary>
254259
/// Determines whether the <see cref="IPath" /> contains the specified point
255260
/// </summary>

0 commit comments

Comments
 (0)