< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 93
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)0%660%
GetValues()100%110%
ContainsCore(...)100%110%
IndexOfAny(...)100%110%
IndexOfAnyExcept(...)100%110%
LastIndexOfAny(...)100%110%
LastIndexOfAnyExcept(...)100%110%
ContainsAny(...)100%110%
ContainsAnyExcept(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/SearchValues/AsciiCharSearchValues.cs

#LineLine coverage
 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
 4using System.Diagnostics;
 5using System.Runtime.CompilerServices;
 6using System.Runtime.InteropServices;
 7using System.Runtime.Intrinsics.Arm;
 8using System.Runtime.Intrinsics.Wasm;
 9using System.Runtime.Intrinsics.X86;
 10using System.Text;
 11
 12namespace System.Buffers
 13{
 14    internal sealed class AsciiCharSearchValues<TOptimizations, TUniqueLowNibble> : SearchValues<char>
 15        where TOptimizations : struct, IndexOfAnyAsciiSearcher.IOptimizations
 16        where TUniqueLowNibble : struct, SearchValues.IRuntimeConst
 17    {
 18        private IndexOfAnyAsciiSearcher.AsciiState _state;
 19
 20        public AsciiCharSearchValues(ReadOnlySpan<char> values)
 21        {
 22            // Despite the name being Ascii, this type may be used with non-ASCII values on ARM or WASM.
 23            // See comments in IndexOfAnyAsciiSearcher.CanUseUniqueLowNibbleSearch.
 024            Debug.Assert(Ascii.IsValid(values) || (TUniqueLowNibble.Value && (AdvSimd.IsSupported || PackedSimd.IsSuppor
 025            Debug.Assert(!values.ContainsAnyInRange((char)byte.MaxValue, char.MaxValue));
 26
 027            if (TUniqueLowNibble.Value)
 28            {
 029                IndexOfAnyAsciiSearcher.ComputeUniqueLowNibbleState(values, out _state);
 30            }
 31            else
 32            {
 033                IndexOfAnyAsciiSearcher.ComputeAsciiState(values, out _state);
 34            }
 035        }
 36
 37        internal override char[] GetValues() =>
 038            _state.Lookup.GetCharValues();
 39
 40        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 41        internal override bool ContainsCore(char value) =>
 042            _state.Lookup.Contains256(value);
 43
 44        [CompExactlyDependsOn(typeof(Ssse3))]
 45        [CompExactlyDependsOn(typeof(AdvSimd))]
 46        [CompExactlyDependsOn(typeof(PackedSimd))]
 47        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 48        internal override int IndexOfAny(ReadOnlySpan<char> span) =>
 049            IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TOptimizations, TUniqueLowNibble>(
 050                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 51
 52        [CompExactlyDependsOn(typeof(Ssse3))]
 53        [CompExactlyDependsOn(typeof(AdvSimd))]
 54        [CompExactlyDependsOn(typeof(PackedSimd))]
 55        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 56        internal override int IndexOfAnyExcept(ReadOnlySpan<char> span) =>
 057            IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.Negate, TOptimizations, TUniqueLowNibble>(
 058                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 59
 60        [CompExactlyDependsOn(typeof(Ssse3))]
 61        [CompExactlyDependsOn(typeof(AdvSimd))]
 62        [CompExactlyDependsOn(typeof(PackedSimd))]
 63        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 64        internal override int LastIndexOfAny(ReadOnlySpan<char> span) =>
 065            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TOptimizations, TUniqueLowNibble>
 066                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 67
 68        [CompExactlyDependsOn(typeof(Ssse3))]
 69        [CompExactlyDependsOn(typeof(AdvSimd))]
 70        [CompExactlyDependsOn(typeof(PackedSimd))]
 71        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 72        internal override int LastIndexOfAnyExcept(ReadOnlySpan<char> span) =>
 073            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate, TOptimizations, TUniqueLowNibble>(
 074                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 75
 76        [CompExactlyDependsOn(typeof(Ssse3))]
 77        [CompExactlyDependsOn(typeof(AdvSimd))]
 78        [CompExactlyDependsOn(typeof(PackedSimd))]
 79        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 80        internal override bool ContainsAny(ReadOnlySpan<char> span) =>
 081            IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.DontNegate, TOptimizations, TUniqueLowNibble>(
 082                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 83
 84        [CompExactlyDependsOn(typeof(Ssse3))]
 85        [CompExactlyDependsOn(typeof(AdvSimd))]
 86        [CompExactlyDependsOn(typeof(PackedSimd))]
 87        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 88        internal override bool ContainsAnyExcept(ReadOnlySpan<char> span) =>
 089            IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.Negate, TOptimizations, TUniqueLowNibble>(
 090                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 91    }
 92}
 93