diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 6d5d2548f6..d3a5ea15b0 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -55,6 +55,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder private ArithmeticDecodingTable[] acDecodingTables; + private readonly byte[] fixedBin = { 113, 0, 0, 0 }; + private readonly CancellationToken cancellationToken; private static readonly int[] ArithmeticTable = @@ -197,9 +199,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder this.ct = -16; // Force reading 2 initial bytes to fill C. } - // Uses C# compiler's optimization to refer to static data segment directly, without any further allocation. - private static ReadOnlySpan FixedBin => new byte[] { 113, 0, 0, 0 }; - /// public int ResetInterval { @@ -234,7 +233,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder } } - private ref byte GetFixedBinReference() => ref MemoryMarshal.GetReference(FixedBin); + private ref byte GetFixedBinReference() => ref this.fixedBin[0]; /// /// Decodes the entropy coded data.