forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
/
IndexOfAny1ByteValue.cs
41 lines (32 loc) · 1.38 KB
/
IndexOfAny1ByteValue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace System.Buffers
{
internal sealed class IndexOfAny1ByteValue : IndexOfAnyValues<byte>
{
private readonly byte _e0;
public IndexOfAny1ByteValue(ReadOnlySpan<byte> values)
{
Debug.Assert(values.Length == 1);
_e0 = values[0];
}
internal override byte[] GetValues() => new[] { _e0 };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal override bool ContainsCore(byte value) =>
value == _e0;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal override int IndexOfAny(ReadOnlySpan<byte> span) =>
span.IndexOf(_e0);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal override int IndexOfAnyExcept(ReadOnlySpan<byte> span) =>
span.IndexOfAnyExcept(_e0);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal override int LastIndexOfAny(ReadOnlySpan<byte> span) =>
span.LastIndexOf(_e0);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal override int LastIndexOfAnyExcept(ReadOnlySpan<byte> span) =>
span.LastIndexOfAnyExcept(_e0);
}
}