| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Runtime.CompilerServices; |
| | | 5 | | using System.Runtime.InteropServices; |
| | | 6 | | using System.Runtime.Intrinsics.X86; |
| | | 7 | | |
| | | 8 | | namespace System.Buffers |
| | | 9 | | { |
| | | 10 | | internal sealed class Any2CharPackedSearchValues : SearchValues<char> |
| | | 11 | | { |
| | | 12 | | private readonly char _e0, _e1; |
| | | 13 | | |
| | 0 | 14 | | public Any2CharPackedSearchValues(char value0, char value1) => |
| | 0 | 15 | | (_e0, _e1) = (value0, value1); |
| | | 16 | | |
| | | 17 | | internal override char[] GetValues() => |
| | 0 | 18 | | [_e0, _e1]; |
| | | 19 | | |
| | | 20 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 21 | | internal override bool ContainsCore(char value) => |
| | 0 | 22 | | value == _e0 || value == _e1; |
| | | 23 | | |
| | | 24 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 25 | | [CompExactlyDependsOn(typeof(Sse2))] |
| | | 26 | | internal override int IndexOfAny(ReadOnlySpan<char> span) => |
| | 0 | 27 | | PackedSpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length); |
| | | 28 | | |
| | | 29 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 30 | | [CompExactlyDependsOn(typeof(Sse2))] |
| | | 31 | | internal override int IndexOfAnyExcept(ReadOnlySpan<char> span) => |
| | 0 | 32 | | PackedSpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length); |
| | | 33 | | |
| | | 34 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 35 | | internal override int LastIndexOfAny(ReadOnlySpan<char> span) => |
| | 0 | 36 | | span.LastIndexOfAny(_e0, _e1); |
| | | 37 | | |
| | | 38 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 39 | | internal override int LastIndexOfAnyExcept(ReadOnlySpan<char> span) => |
| | 0 | 40 | | span.LastIndexOfAnyExcept(_e0, _e1); |
| | | 41 | | } |
| | | 42 | | } |
| | | 43 | | |