From 3354ae68d7046cadf3d9e07110f2725aa87475c8 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Fri, 7 Jan 2022 20:01:49 +0300 Subject: [PATCH] Reduced stackallock pressure by changing char to byte --- .../Formats/Jpeg/Components/Decoder/HuffmanTable.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanTable.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanTable.cs index 26df55738a..c20ea1e584 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanTable.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanTable.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder Unsafe.CopyBlockUnaligned(ref this.Values[0], ref MemoryMarshal.GetReference(values), (uint)values.Length); // TODO: testing code - Span huffSize = stackalloc char[257]; + Span huffSize = stackalloc byte[257]; Span huffCode = stackalloc uint[257]; // Figure C.1: make table of Huffman code length for each symbol @@ -68,11 +68,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder int i = codeLengths[j]; while (i-- != 0) { - huffSize[p++] = (char)j; + huffSize[p++] = (byte)j; } } - huffSize[p] = (char)0; + huffSize[p] = 0; // Figure C.2: generate the codes themselves uint code = 0;