From c6e583991c1916b7f39adf45da20a1510cd31e35 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 7 Feb 2023 21:56:08 +1000 Subject: [PATCH] Minor cleanup --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 8 ++++---- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 4 +--- src/ImageSharp/Image.cs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 6c82d61e1..3ebd65a67 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -337,9 +337,9 @@ internal sealed class GifDecoderCore : IImageDecoderInternals /// /// Skips over a block or reads its terminator. - /// The length of the block to skip. - /// The containing image data. /// + /// The containing image data. + /// The length of the block to skip. private static void SkipBlock(BufferedReadStream stream, int blockSize = 0) { if (blockSize > 0) @@ -363,7 +363,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals { int length; - StringBuilder stringBuilder = new StringBuilder(); + StringBuilder stringBuilder = new(); while ((length = stream.ReadByte()) != 0) { if (length > GifConstants.MaxCommentSubBlockLength) @@ -450,7 +450,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals private void ReadFrameIndices(BufferedReadStream stream, Buffer2D indices) { int minCodeSize = stream.ReadByte(); - using LzwDecoder lzwDecoder = new LzwDecoder(this.configuration.MemoryAllocator, stream); + using LzwDecoder lzwDecoder = new(this.configuration.MemoryAllocator, stream); lzwDecoder.DecodePixels(minCodeSize, indices); } diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 0e59a0f05..75c9b1186 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -2,7 +2,6 @@ // Licensed under the Six Labors Split License. using System.Buffers; -using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using SixLabors.ImageSharp.Advanced; @@ -141,7 +140,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals private void EncodeFrames( Stream stream, Image image, - IndexedImageFrame? quantized, + IndexedImageFrame quantized, ReadOnlyMemory palette) where TPixel : unmanaged, IPixel { @@ -168,7 +167,6 @@ internal sealed class GifEncoderCore : IImageEncoderInternals // Clean up for the next run. quantized.Dispose(); - quantized = null; } if (hasPaletteQuantizer) diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index af1b1916f..02fa01478 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -30,7 +30,7 @@ public abstract partial class Image : ImageInfo, IDisposable, IConfigurationProv /// The size in px units. protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata? metadata, Size size) : base(pixelType, size, metadata) - => this.configuration = configuration ?? Configuration.Default; + => this.configuration = configuration; /// /// Initializes a new instance of the class.