|
| 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 AsciiWithSecondSetCharSearchValues<TOptimizations> : SearchValues<char> |
| 13 | + where TOptimizations : struct, IndexOfAnyAsciiSearcher.IOptimizations |
| 14 | + { |
| 15 | + private IndexOfAnyAsciiSearcher.AsciiWithSecondSetState _state; |
| 16 | + |
| 17 | + public AsciiWithSecondSetCharSearchValues(IndexOfAnyAsciiSearcher.AsciiWithSecondSetState state) => |
| 18 | + _state = state; |
| 19 | + |
| 20 | + internal override char[] GetValues() => |
| 21 | + _state.Lookup.GetValues(); |
| 22 | + |
| 23 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 24 | + internal override bool ContainsCore(char value) => |
| 25 | + _state.Lookup.FastContains(value); |
| 26 | + |
| 27 | + [CompExactlyDependsOn(typeof(Ssse3))] |
| 28 | + [CompExactlyDependsOn(typeof(AdvSimd))] |
| 29 | + [CompExactlyDependsOn(typeof(PackedSimd))] |
| 30 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 31 | + internal override int IndexOfAny(ReadOnlySpan<char> span) => |
| 32 | + IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TOptimizations>( |
| 33 | + ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); |
| 34 | + |
| 35 | + [CompExactlyDependsOn(typeof(Ssse3))] |
| 36 | + [CompExactlyDependsOn(typeof(AdvSimd))] |
| 37 | + [CompExactlyDependsOn(typeof(PackedSimd))] |
| 38 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 39 | + internal override int IndexOfAnyExcept(ReadOnlySpan<char> span) => |
| 40 | + IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.Negate, TOptimizations>( |
| 41 | + ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); |
| 42 | + |
| 43 | + [CompExactlyDependsOn(typeof(Ssse3))] |
| 44 | + [CompExactlyDependsOn(typeof(AdvSimd))] |
| 45 | + [CompExactlyDependsOn(typeof(PackedSimd))] |
| 46 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 47 | + internal override int LastIndexOfAny(ReadOnlySpan<char> span) => |
| 48 | + IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TOptimizations>( |
| 49 | + ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); |
| 50 | + |
| 51 | + [CompExactlyDependsOn(typeof(Ssse3))] |
| 52 | + [CompExactlyDependsOn(typeof(AdvSimd))] |
| 53 | + [CompExactlyDependsOn(typeof(PackedSimd))] |
| 54 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 55 | + internal override int LastIndexOfAnyExcept(ReadOnlySpan<char> span) => |
| 56 | + IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate, TOptimizations>( |
| 57 | + ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); |
| 58 | + |
| 59 | + [CompExactlyDependsOn(typeof(Ssse3))] |
| 60 | + [CompExactlyDependsOn(typeof(AdvSimd))] |
| 61 | + [CompExactlyDependsOn(typeof(PackedSimd))] |
| 62 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 63 | + internal override bool ContainsAny(ReadOnlySpan<char> span) => |
| 64 | + IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.DontNegate, TOptimizations>( |
| 65 | + ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); |
| 66 | + |
| 67 | + [CompExactlyDependsOn(typeof(Ssse3))] |
| 68 | + [CompExactlyDependsOn(typeof(AdvSimd))] |
| 69 | + [CompExactlyDependsOn(typeof(PackedSimd))] |
| 70 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 71 | + internal override bool ContainsAnyExcept(ReadOnlySpan<char> span) => |
| 72 | + IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.Negate, TOptimizations>( |
| 73 | + ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); |
| 74 | + } |
| 75 | +} |
0 commit comments