diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 3493e52c7..b6348803a 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -263,12 +263,7 @@ namespace SixLabors.ImageSharp.Formats.Gif if (appLength == GifConstants.ApplicationBlockSize) { this.stream.Read(this.buffer, 0, GifConstants.ApplicationBlockSize); - bool isXmp = true; - ReadOnlySpan idBytes = GifConstants.XmpApplicationIdentificationBytes; - for (int i = 0; i < idBytes.Length; i++) - { - isXmp &= this.buffer[i] == idBytes[i]; - } + bool isXmp = this.buffer.AsSpan().StartsWith(GifConstants.XmpApplicationIdentificationBytes); if (isXmp) { diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 891a16fc7..b32e79299 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -1371,20 +1371,7 @@ namespace SixLabors.ImageSharp.Formats.Png return true; } - private bool IsXmpTextData(ReadOnlySpan keywordBytes) - { - ReadOnlySpan expected = PngConstants.XmpKeyword; - bool result = keywordBytes.Length == expected.Length; - if (result) - { - for (int i = 0; i < keywordBytes.Length; i++) - { - result |= keywordBytes[i] == expected[i]; - } - } - - return result; - } + private bool IsXmpTextData(ReadOnlySpan keywordBytes) => keywordBytes.SequenceEqual(PngConstants.XmpKeyword); private void SwapScanlineBuffers() {