| | | 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 Any1CharPackedSearchValues : SearchValues<char> |
| | | 11 | | { |
| | | 12 | | private readonly char _e0; |
| | | 13 | | |
| | 375 | 14 | | public Any1CharPackedSearchValues(char value) => |
| | 375 | 15 | | _e0 = value; |
| | | 16 | | |
| | | 17 | | internal override char[] GetValues() => |
| | 0 | 18 | | [_e0]; |
| | | 19 | | |
| | | 20 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 21 | | internal override bool ContainsCore(char value) => |
| | 81141 | 22 | | value == _e0; |
| | | 23 | | |
| | | 24 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 25 | | [CompExactlyDependsOn(typeof(Sse2))] |
| | | 26 | | internal override int IndexOfAny(ReadOnlySpan<char> span) => |
| | 1500 | 27 | | PackedSpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), _e0, span.Length); |
| | | 28 | | |
| | | 29 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 30 | | [CompExactlyDependsOn(typeof(Sse2))] |
| | | 31 | | internal override int IndexOfAnyExcept(ReadOnlySpan<char> span) => |
| | 1500 | 32 | | PackedSpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), _e0, span.Length); |
| | | 33 | | |
| | | 34 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 35 | | internal override int LastIndexOfAny(ReadOnlySpan<char> span) => |
| | 750 | 36 | | span.LastIndexOf(_e0); |
| | | 37 | | |
| | | 38 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 39 | | internal override int LastIndexOfAnyExcept(ReadOnlySpan<char> span) => |
| | 750 | 40 | | span.LastIndexOfAnyExcept(_e0); |
| | | 41 | | } |
| | | 42 | | } |
| | | 43 | | |