From e3a7bb40c55fa95a1ca44108a6ec6cbfd76ae346 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 6 Feb 2020 09:32:56 +1100 Subject: [PATCH] Remove final allocations --- .../Advanced/ParallelUtils/IRowIntervalAction.cs | 8 ++------ .../Advanced/ParallelUtils/IRowIntervalAction{TBuffer}.cs | 8 ++------ src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs | 5 ++--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction.cs b/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction.cs index 830fcf736..cb38b89bd 100644 --- a/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction.cs +++ b/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils } } - internal readonly struct WrappingRowIntervalAction : IRowIntervalAction + internal readonly struct WrappingRowIntervalAction where T : struct, IRowIntervalAction { private readonly WrappingRowIntervalInfo info; @@ -63,13 +63,9 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils } int yMax = Math.Min(yMin + this.info.StepY, this.info.MaxY); - var rows = new RowInterval(yMin, yMax); - this.Invoke(in rows); + this.action.Invoke(in rows); } - - [MethodImpl(InliningOptions.ShortMethod)] - public void Invoke(in RowInterval rows) => this.action.Invoke(in rows); } } diff --git a/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction{TBuffer}.cs b/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction{TBuffer}.cs index c0899ad3a..6943405cd 100644 --- a/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction{TBuffer}.cs +++ b/src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction{TBuffer}.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils void Invoke(in RowInterval rows, Memory memory); } - internal readonly struct WrappingRowIntervalAction : IRowIntervalAction + internal readonly struct WrappingRowIntervalAction where T : struct, IRowIntervalAction where TBuffer : unmanaged { @@ -52,16 +52,12 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils } int yMax = Math.Min(yMin + this.info.StepY, this.info.MaxY); - var rows = new RowInterval(yMin, yMax); using (IMemoryOwner buffer = this.allocator.Allocate(this.info.MaxX)) { - this.Invoke(in rows, buffer.Memory); + this.action.Invoke(in rows, buffer.Memory); } } - - [MethodImpl(InliningOptions.ShortMethod)] - public void Invoke(in RowInterval rows, Memory memory) => this.action.Invoke(in rows, memory); } } diff --git a/src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs b/src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs index 92c2ff20f..ea975a0ee 100644 --- a/src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs +++ b/src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils 0, numOfSteps, parallelOptions, - i => rowAction.Invoke(i)); + rowAction.Invoke); } /// @@ -136,8 +136,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils 0, numOfSteps, parallelOptions, - i => - rowAction.Invoke(i)); + rowAction.Invoke); } ///