Browse Source

avoiding unnecessary allocation of the exif id byte array in StartsWithExifIdCode()

pull/616/head
popow 8 years ago
parent
commit
e26ea4934f
  1. 13
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

13
src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

@ -15,6 +15,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// </summary> /// </summary>
public sealed class ExifProfile public sealed class ExifProfile
{ {
/// <summary>
/// The EXIF ID code: ASCII "Exif" followed by two zeros.
/// </summary>
private static readonly byte[] ExifCode = { 69, 120, 105, 102, 0, 0 };
/// <summary> /// <summary>
/// The byte array to read the EXIF profile from. /// The byte array to read the EXIF profile from.
/// </summary> /// </summary>
@ -270,12 +275,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
return false; return false;
} }
// The EXIF ID code: ASCII "Exif" followed by two zeros. int exifLength = ExifCode.Length;
byte[] exifCode = { 69, 120, 105, 102, 0, 0 }; for (int i = 0; i < ExifCode.Length; i++)
int exifLength = exifCode.Length;
for (int i = 0; i < exifCode.Length; i++)
{ {
if (exifBytes[i] != exifCode[i]) if (exifBytes[i] != ExifCode[i])
{ {
return false; return false;
} }

Loading…
Cancel
Save