Skip to content

Commit

Permalink
Minor refactoring inside some of the IsSupportedFileFormat methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Lemstra committed Dec 19, 2016
1 parent a0abb9f commit fdca608
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
11 changes: 3 additions & 8 deletions src/ImageSharp/Formats/Bmp/BmpFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ public class BmpFormat : IImageFormat
/// <inheritdoc/>
public bool IsSupportedFileFormat(byte[] header)
{
bool isBmp = false;
if (header.Length >= this.HeaderSize)
{
isBmp = header[0] == 0x42 && // B
header[1] == 0x4D; // M
}

return isBmp;
return header.Length >= this.HeaderSize &&
header[0] == 0x42 && // B
header[1] == 0x4D; // M
}
}
}
16 changes: 2 additions & 14 deletions src/ImageSharp/Formats/Jpg/JpegFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,8 @@ public class JpegFormat : IImageFormat
/// <inheritdoc/>
public bool IsSupportedFileFormat(byte[] header)
{
Guard.NotNull(header, "header");

bool isSupported = false;

if (header.Length >= this.HeaderSize)
{
bool isJfif = IsJfif(header);
bool isExif = IsExif(header);
bool isJpeg = IsJpeg(header);

isSupported = isJfif || isExif || isJpeg;
}

return isSupported;
return header.Length >= this.HeaderSize &&
(IsJfif(header) || IsExif(header) || IsJpeg(header));
}

/// <summary>
Expand Down

0 comments on commit fdca608

Please sign in to comment.