mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 58 additions and 11 deletions
@ -0,0 +1,22 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// Uncomment this for verbose profiler results:
|
||||
|
// #define PROFILING
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Global inlining options. Helps temporally disable inling for better profiler output.
|
||||
|
/// </summary>
|
||||
|
internal static class InliningOptions |
||||
|
{ |
||||
|
#if PROFILING
|
||||
|
public const MethodImplOptions ShortMethod = 0; |
||||
|
#else
|
||||
|
public const MethodImplOptions ShortMethod = MethodImplOptions.AggressiveInlining; |
||||
|
#endif
|
||||
|
public const MethodImplOptions ColdPath = MethodImplOptions.NoInlining; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.Jpeg |
||||
|
{ |
||||
|
internal static class JpegThrowHelper |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Cold path optimization for throwing <see cref="ImageFormatException"/>-s
|
||||
|
/// </summary>
|
||||
|
/// <param name="errorMessage">The error message for the exception</param>
|
||||
|
[MethodImpl(MethodImplOptions.NoInlining)] |
||||
|
public static void ThrowImageFormatException(string errorMessage) |
||||
|
{ |
||||
|
throw new ImageFormatException(errorMessage); |
||||
|
} |
||||
|
|
||||
|
[MethodImpl(MethodImplOptions.NoInlining)] |
||||
|
public static void ThrowBadHuffmanCode() |
||||
|
{ |
||||
|
throw new ImageFormatException("Bad Huffman code."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue