diff --git a/src/ImageSharp/Formats/Jpeg/Components/RowOctet.cs b/src/ImageSharp/Formats/Jpeg/Components/RowOctet.cs index 57a134703..8c3daa4d5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/RowOctet.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/RowOctet.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using SixLabors.ImageSharp.Memory; @@ -39,6 +40,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components public Span this[int y] { + [MethodImpl(InliningOptions.ShortMethod)] get { // No unsafe tricks, since Span can't be used as a generic argument @@ -52,9 +54,15 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components 5 => this.row5, 6 => this.row6, 7 => this.row7, - _ => throw new IndexOutOfRangeException() + _ => ThrowIndexOutOfRangeException() }; } } + + [MethodImpl(InliningOptions.ColdPath)] + private static Span ThrowIndexOutOfRangeException() + { + throw new IndexOutOfRangeException(); + } } }