Browse Source

optimize RowOctet<T> indexer

pull/1109/head
Anton Firszov 6 years ago
parent
commit
ad2632f1cd
  1. 10
      src/ImageSharp/Formats/Jpeg/Components/RowOctet.cs

10
src/ImageSharp/Formats/Jpeg/Components/RowOctet.cs

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

Loading…
Cancel
Save