From 67fd2d0427290e6a76eec0e49fb133986efbf3b6 Mon Sep 17 00:00:00 2001 From: Brian Popow <38701097+brianpopow@users.noreply.github.com> Date: Mon, 1 Nov 2021 13:07:39 +0100 Subject: [PATCH] Use ReadOnlySpan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Günther Foidl --- src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs | 3 ++- src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index abb727447..c6dc6b8b2 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs @@ -17,7 +17,8 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless /// internal static unsafe class PredictorEncoder { - private static readonly sbyte[] DeltaLut = { 16, 16, 8, 4, 2, 2, 2 }; + // This uses C#'s compiler optimization to refer to assembly's static data directly. + private static ReadOnlySpan DeltaLut => new sbyte[] { 16, 16, 8, 4, 2, 2, 2 }; private static readonly sbyte[][] Offset = { diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index c46e7193f..1a9036ec9 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -85,7 +85,8 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless private const int PaletteInvSize = 1 << PaletteInvSizeBits; - private static readonly byte[] Order = { 1, 2, 0, 3 }; + // This uses C#'s compiler optimization to refer to assembly's static data directly. + private static ReadOnlySpan Order => new byte[] { 1, 2, 0, 3 }; /// /// Initializes a new instance of the class.