From 77cdbbb8da94e0c620f04c695c522eaf1826a450 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Fri, 13 Aug 2021 21:25:30 +0200 Subject: [PATCH] Use ReadOnlySpan for componentId's --- src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 18d31d978c..dc84a161fb 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg // Compute number of components based on color type in options. int componentCount = (this.colorType == JpegColorType.Luminance) ? 1 : 3; - byte[] componentIds = this.GetComponentIds(); + ReadOnlySpan componentIds = this.GetComponentIds(); // TODO: Right now encoder writes both quantization tables for grayscale images - we shouldn't do that // Initialize the quantization tables. @@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// For color space RGB this will be RGB as ASCII, otherwise 1, 2, 3. /// /// The component Ids. - private byte[] GetComponentIds() + private ReadOnlySpan GetComponentIds() { if (this.colorType == JpegColorType.Rgb) { @@ -508,7 +508,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The height of the image. /// The number of components in a pixel. /// The component Id's. - private void WriteStartOfFrame(int width, int height, int componentCount, byte[] componentIds) + private void WriteStartOfFrame(int width, int height, int componentCount, ReadOnlySpan componentIds) { // "default" to 4:2:0 Span subsamples = stackalloc byte[] @@ -586,7 +586,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// /// The number of components in a pixel. /// The componentId's. - private void WriteStartOfScan(int componentCount, byte[] componentIds) + private void WriteStartOfScan(int componentCount, ReadOnlySpan componentIds) { Span huffmanId = stackalloc byte[] {