Browse Source

Removed unused methods, added new throw helper method

pull/1899/head
Dmitry Pentin 4 years ago
parent
commit
1f9ef3e926
  1. 4
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  2. 20
      src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs

4
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -1033,13 +1033,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
// Validate: 1-4 range
if (h is < 1 or > 4)
{
JpegThrowHelper.ThrowInvalidImageContentException($"Bad horizontal sampling factor: {h}");
JpegThrowHelper.ThrowBadSampling(h);
}
// Validate: 1-4 range
if (v is < 1 or > 4)
{
JpegThrowHelper.ThrowInvalidImageContentException($"Bad vertical sampling factor: {v}");
JpegThrowHelper.ThrowBadSampling(v);
}
if (maxH < h)

20
src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs

@ -22,23 +22,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);
/// <summary>
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s.
/// </summary>
/// <param name="errorMessage">The error message for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// if no inner exception is specified.</param>
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException) => throw new InvalidImageContentException(errorMessage, innerException);
/// <summary>
/// Cold path optimization for throwing <see cref="NotImplementedException"/>'s
/// </summary>
/// <param name="errorMessage">The error message for the exception.</param>
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowNotImplementedException(string errorMessage)
=> throw new NotImplementedException(errorMessage);
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowBadMarker(string marker, int length) => throw new InvalidImageContentException($"Marker {marker} has bad length {length}.");
@ -51,6 +34,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowBadSampling() => throw new InvalidImageContentException("Bad sampling factor.");
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowBadSampling(int factor) => throw new InvalidImageContentException($"Bad sampling factor: {factor}");
[MethodImpl(InliningOptions.ColdPath)]
public static void ThrowBadProgressiveScan(int ss, int se, int ah, int al) => throw new InvalidImageContentException($"Invalid progressive parameters Ss={ss} Se={se} Ah={ah} Al={al}.");

Loading…
Cancel
Save