From c4aceae4a6efddae8acb482b8611382e95c24e03 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 25 Jun 2017 09:42:01 +0100 Subject: [PATCH] use buffer instead of array pool directly --- src/ImageSharp.Drawing/Paths/ShapeRegion.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs index 51093c5d9c..a7a72c4f3c 100644 --- a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Drawing using System; using System.Buffers; using System.Numerics; + using ImageSharp.Memory; using SixLabors.Primitives; using SixLabors.Shapes; @@ -45,24 +46,20 @@ namespace ImageSharp.Drawing /// public override int Scan(float y, Span buffer) { - PointF start = new PointF(this.Bounds.Left - 1, y); - PointF end = new PointF(this.Bounds.Right + 1, y); - PointF[] innerbuffer = ArrayPool.Shared.Rent(buffer.Length); - try + var start = new PointF(this.Bounds.Left - 1, y); + var end = new PointF(this.Bounds.Right + 1, y); + using (var innerBuffer = new Buffer(buffer.Length)) { - int count = this.Shape.FindIntersections(start, end, innerbuffer); + var span = innerBuffer.Span; + int count = this.Shape.FindIntersections(start, end, span); for (int i = 0; i < count; i++) { - buffer[i] = innerbuffer[i].X; + buffer[i] = span[i].X; } return count; } - finally - { - ArrayPool.Shared.Return(innerbuffer); - } } } -} +} \ No newline at end of file