Browse Source

Performance improvements

pull/1918/head
Ynse Hoornenborg 4 years ago
parent
commit
06beffb2db
  1. 7
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  2. 15
      src/ImageSharp/Formats/Png/PngDecoderCore.cs

7
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<byte> 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)
{

15
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -1371,20 +1371,7 @@ namespace SixLabors.ImageSharp.Formats.Png
return true;
}
private bool IsXmpTextData(ReadOnlySpan<byte> keywordBytes)
{
ReadOnlySpan<byte> 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<byte> keywordBytes) => keywordBytes.SequenceEqual(PngConstants.XmpKeyword);
private void SwapScanlineBuffers()
{

Loading…
Cancel
Save