< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 91
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/AsciiByteSearchValues.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 AsciiByteSearchValues<TUniqueLowNibble> : SearchValues<byte>
 15        where TUniqueLowNibble : struct, SearchValues.IRuntimeConst
 16    {
 17        private IndexOfAnyAsciiSearcher.AsciiState _state;
 18
 19        public AsciiByteSearchValues(ReadOnlySpan<byte> values)
 20        {
 21            // Despite the name being Ascii, this type may be used with non-ASCII values on ARM or WASM.
 22            // See comments in IndexOfAnyAsciiSearcher.CanUseUniqueLowNibbleSearch.
 023            Debug.Assert(Ascii.IsValid(values) || (TUniqueLowNibble.Value && (AdvSimd.IsSupported || PackedSimd.IsSuppor
 24
 025            if (TUniqueLowNibble.Value)
 26            {
 027                IndexOfAnyAsciiSearcher.ComputeUniqueLowNibbleState(values, out _state);
 28            }
 29            else
 30            {
 031                IndexOfAnyAsciiSearcher.ComputeAsciiState(values, out _state);
 32            }
 033        }
 34
 35        internal override byte[] GetValues() =>
 036            _state.Lookup.GetByteValues();
 37
 38        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 39        internal override bool ContainsCore(byte value) =>
 040            _state.Lookup.Contains(value);
 41
 42        [CompExactlyDependsOn(typeof(Ssse3))]
 43        [CompExactlyDependsOn(typeof(AdvSimd))]
 44        [CompExactlyDependsOn(typeof(PackedSimd))]
 45        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 46        internal override int IndexOfAny(ReadOnlySpan<byte> span) =>
 047            IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TUniqueLowNibble>(
 048                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 IndexOfAnyExcept(ReadOnlySpan<byte> span) =>
 055            IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.Negate, TUniqueLowNibble>(
 056                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 int LastIndexOfAny(ReadOnlySpan<byte> span) =>
 063            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TUniqueLowNibble>(
 064                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 int LastIndexOfAnyExcept(ReadOnlySpan<byte> span) =>
 071            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate, TUniqueLowNibble>(
 072                ref MemoryMarshal.GetReference(span), span.Length, ref _state);
 73
 74        [CompExactlyDependsOn(typeof(Ssse3))]
 75        [CompExactlyDependsOn(typeof(AdvSimd))]
 76        [CompExactlyDependsOn(typeof(PackedSimd))]
 77        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 78        internal override bool ContainsAny(ReadOnlySpan<byte> span) =>
 079            IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.DontNegate, TUniqueLowNibble>(
 080                ref MemoryMarshal.GetReference(span), span.Length, ref _state);
 81
 82        [CompExactlyDependsOn(typeof(Ssse3))]
 83        [CompExactlyDependsOn(typeof(AdvSimd))]
 84        [CompExactlyDependsOn(typeof(PackedSimd))]
 85        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 86        internal override bool ContainsAnyExcept(ReadOnlySpan<byte> span) =>
 087            IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.Negate, TUniqueLowNibble>(
 088                ref MemoryMarshal.GetReference(span), span.Length, ref _state);
 89    }
 90}
 91