| | | 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.Arm; |
| | | 7 | | using System.Runtime.Intrinsics.Wasm; |
| | | 8 | | using System.Runtime.Intrinsics.X86; |
| | | 9 | | |
| | | 10 | | namespace System.Buffers |
| | | 11 | | { |
| | | 12 | | internal sealed class AnyByteSearchValues : SearchValues<byte> |
| | | 13 | | { |
| | | 14 | | private IndexOfAnyAsciiSearcher.AnyByteState _state; |
| | | 15 | | |
| | 0 | 16 | | public AnyByteSearchValues(ReadOnlySpan<byte> values) => |
| | 0 | 17 | | IndexOfAnyAsciiSearcher.ComputeAnyByteState(values, out _state); |
| | | 18 | | |
| | | 19 | | internal override byte[] GetValues() => |
| | 0 | 20 | | _state.Lookup.GetByteValues(); |
| | | 21 | | |
| | | 22 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 23 | | internal override bool ContainsCore(byte value) => |
| | 0 | 24 | | _state.Lookup.Contains(value); |
| | | 25 | | |
| | | 26 | | [CompExactlyDependsOn(typeof(Ssse3))] |
| | | 27 | | [CompExactlyDependsOn(typeof(AdvSimd))] |
| | | 28 | | [CompExactlyDependsOn(typeof(PackedSimd))] |
| | | 29 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 30 | | internal override int IndexOfAny(ReadOnlySpan<byte> span) => |
| | 0 | 31 | | IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.DontNegate>( |
| | 0 | 32 | | ref MemoryMarshal.GetReference(span), span.Length, ref _state); |
| | | 33 | | |
| | | 34 | | [CompExactlyDependsOn(typeof(Ssse3))] |
| | | 35 | | [CompExactlyDependsOn(typeof(AdvSimd))] |
| | | 36 | | [CompExactlyDependsOn(typeof(PackedSimd))] |
| | | 37 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 38 | | internal override int IndexOfAnyExcept(ReadOnlySpan<byte> span) => |
| | 0 | 39 | | IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.Negate>( |
| | 0 | 40 | | ref MemoryMarshal.GetReference(span), span.Length, ref _state); |
| | | 41 | | |
| | | 42 | | [CompExactlyDependsOn(typeof(Ssse3))] |
| | | 43 | | [CompExactlyDependsOn(typeof(AdvSimd))] |
| | | 44 | | [CompExactlyDependsOn(typeof(PackedSimd))] |
| | | 45 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 46 | | internal override int LastIndexOfAny(ReadOnlySpan<byte> span) => |
| | 0 | 47 | | IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate>( |
| | 0 | 48 | | ref MemoryMarshal.GetReference(span), span.Length, ref _state); |
| | | 49 | | |
| | | 50 | | [CompExactlyDependsOn(typeof(Ssse3))] |
| | | 51 | | [CompExactlyDependsOn(typeof(AdvSimd))] |
| | | 52 | | [CompExactlyDependsOn(typeof(PackedSimd))] |
| | | 53 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 54 | | internal override int LastIndexOfAnyExcept(ReadOnlySpan<byte> span) => |
| | 0 | 55 | | IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate>( |
| | 0 | 56 | | ref MemoryMarshal.GetReference(span), span.Length, ref _state); |
| | | 57 | | |
| | | 58 | | [CompExactlyDependsOn(typeof(Ssse3))] |
| | | 59 | | [CompExactlyDependsOn(typeof(AdvSimd))] |
| | | 60 | | [CompExactlyDependsOn(typeof(PackedSimd))] |
| | | 61 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 62 | | internal override bool ContainsAny(ReadOnlySpan<byte> span) => |
| | 0 | 63 | | IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.DontNegate>( |
| | 0 | 64 | | ref MemoryMarshal.GetReference(span), span.Length, ref _state); |
| | | 65 | | |
| | | 66 | | [CompExactlyDependsOn(typeof(Ssse3))] |
| | | 67 | | [CompExactlyDependsOn(typeof(AdvSimd))] |
| | | 68 | | [CompExactlyDependsOn(typeof(PackedSimd))] |
| | | 69 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 70 | | internal override bool ContainsAnyExcept(ReadOnlySpan<byte> span) => |
| | 0 | 71 | | IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.Negate>( |
| | 0 | 72 | | ref MemoryMarshal.GetReference(span), span.Length, ref _state); |
| | | 73 | | } |
| | | 74 | | } |
| | | 75 | | |