Browse Source

Revert "Eliminate allocation processing the identifier in ProcessApp2Marker"

This reverts commit e4bddc786f.
af/merge-core
Jason Nelson 8 years ago
parent
commit
069653d61e
  1. 14
      src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs

14
src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs

@ -482,20 +482,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
private void ProcessApp2Marker(int remaining) private void ProcessApp2Marker(int remaining)
{ {
// Length is 14 though we only need to check 12. // Length is 14 though we only need to check 12.
const int IccLength = 14; const int Icclength = 14;
if (remaining < IccLength || this.IgnoreMetadata) if (remaining < Icclength || this.IgnoreMetadata)
{ {
this.InputStream.Skip(remaining); this.InputStream.Skip(remaining);
return; return;
} }
#if NETCOREAPP2_1 byte[] identifier = new byte[Icclength];
byte[] identifier = new byte[IccLength]; // 14 bytes this.InputStream.Read(identifier, 0, Icclength);
#else remaining -= Icclength; // We have read it by this point
Span<byte> identifer = stackalloc byte[IccLength];
#endif
this.InputStream.Read(identifier, 0, IccLength);
remaining -= IccLength; // We have read it by this point
if (ProfileResolver.IsProfile(identifier, ProfileResolver.IccMarker)) if (ProfileResolver.IsProfile(identifier, ProfileResolver.IccMarker))
{ {

Loading…
Cancel
Save