From 382b5bc1f155a0e2f9dbc68b52704e22d3aa704b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 4 Nov 2020 17:31:27 +0000 Subject: [PATCH] Inline controls as constants --- .../Helpers/Shuffle/IComponentShuffle.cs | 32 ++++++++++++------- .../Common/Helpers/Shuffle/IPad3Shuffle4.cs | 8 +++-- .../Common/Helpers/Shuffle/IShuffle4Slice3.cs | 8 +++-- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs index 2056075e7c..7687a5b95f 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs @@ -82,9 +82,11 @@ namespace SixLabors.ImageSharp internal readonly struct WXYZShuffle4 : IShuffle4 { - private static readonly byte WXYZ = SimdUtils.Shuffle.MmShuffle(2, 1, 0, 3); - - public byte Control => WXYZ; + public byte Control + { + [MethodImpl(InliningOptions.ShortMethod)] + get => SimdUtils.Shuffle.MmShuffle(2, 1, 0, 3); + } [MethodImpl(InliningOptions.ShortMethod)] public void RunFallbackShuffle(ReadOnlySpan source, Span dest) @@ -106,9 +108,11 @@ namespace SixLabors.ImageSharp internal readonly struct WZYXShuffle4 : IShuffle4 { - private static readonly byte WZYX = SimdUtils.Shuffle.MmShuffle(0, 1, 2, 3); - - public byte Control => WZYX; + public byte Control + { + [MethodImpl(InliningOptions.ShortMethod)] + get => SimdUtils.Shuffle.MmShuffle(0, 1, 2, 3); + } [MethodImpl(InliningOptions.ShortMethod)] public void RunFallbackShuffle(ReadOnlySpan source, Span dest) @@ -130,9 +134,11 @@ namespace SixLabors.ImageSharp internal readonly struct YZWXShuffle4 : IShuffle4 { - private static readonly byte YZWX = SimdUtils.Shuffle.MmShuffle(0, 3, 2, 1); - - public byte Control => YZWX; + public byte Control + { + [MethodImpl(InliningOptions.ShortMethod)] + get => SimdUtils.Shuffle.MmShuffle(0, 3, 2, 1); + } [MethodImpl(InliningOptions.ShortMethod)] public void RunFallbackShuffle(ReadOnlySpan source, Span dest) @@ -154,9 +160,11 @@ namespace SixLabors.ImageSharp internal readonly struct ZYXWShuffle4 : IShuffle4 { - private static readonly byte ZYXW = SimdUtils.Shuffle.MmShuffle(3, 0, 1, 2); - - public byte Control => ZYXW; + public byte Control + { + [MethodImpl(InliningOptions.ShortMethod)] + get => SimdUtils.Shuffle.MmShuffle(3, 0, 1, 2); + } [MethodImpl(InliningOptions.ShortMethod)] public void RunFallbackShuffle(ReadOnlySpan source, Span dest) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs index fbd4a343db..0c2b1d5082 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs @@ -65,9 +65,11 @@ namespace SixLabors.ImageSharp internal readonly struct XYZWPad3Shuffle4 : IPad3Shuffle4 { - private static readonly byte XYZW = SimdUtils.Shuffle.MmShuffle(3, 2, 1, 0); - - public byte Control => XYZW; + public byte Control + { + [MethodImpl(InliningOptions.ShortMethod)] + get => SimdUtils.Shuffle.MmShuffle(3, 2, 1, 0); + } [MethodImpl(InliningOptions.ShortMethod)] public void RunFallbackShuffle(ReadOnlySpan source, Span dest) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs index e11956c105..86e4174f11 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs @@ -54,9 +54,11 @@ namespace SixLabors.ImageSharp internal readonly struct XYZWShuffle4Slice3 : IShuffle4Slice3 { - private static readonly byte XYZW = SimdUtils.Shuffle.MmShuffle(3, 2, 1, 0); - - public byte Control => XYZW; + public byte Control + { + [MethodImpl(InliningOptions.ShortMethod)] + get => SimdUtils.Shuffle.MmShuffle(3, 2, 1, 0); + } [MethodImpl(InliningOptions.ShortMethod)] public void RunFallbackShuffle(ReadOnlySpan source, Span dest)