Drops some array bounds checks.
Run the following benchmark to compare asm:
Benchmark Source
```csharp
[DisassemblyDiagnoser]
[ShortRunJob]
public class Program
{
private static ReadOnlySpan Data => new byte[8]
{
1,2,3,4,5,6,7,8
};
public IEnumerable Param()
{
yield return 1;
}
[Benchmark]
[ArgumentsSource(nameof(Param))]
public int AccessNoBoundsChekcs(byte c)
{
return Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(Data), (IntPtr)c);
}
[Benchmark]
[ArgumentsSource(nameof(Param))]
public int AccessBoundsChekcs(byte c)
{
return Data[c];
}
static void Main()
{
BenchmarkRunner.Run();
}
}
```
@tkp1n thanks! just benchmarked it and I see some improvement.
I guess the latest roslyn should handle cases like these now since https://github.com/dotnet/roslyn/pull/24621 is merged.
Drops some array bounds checks. Run the following benchmark to compare asm:
Benchmark Source
```csharp [DisassemblyDiagnoser] [ShortRunJob] public class Program { private static ReadOnlySpan