< Summary

Information
Class: System.Buffers.AsciiByteSearchValues<T>
Assembly: System.Private.CoreLib
File(s): D:\runner\runtime\src\libraries\System.Private.CoreLib\src\System\SearchValues\AsciiByteSearchValues.cs
Line coverage
94%
Covered lines: 18
Uncovered lines: 1
Coverable lines: 19
Total lines: 90
Line coverage: 94.7%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

D:\runner\runtime\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.
 217523            Debug.Assert(Ascii.IsValid(values) || (TUniqueLowNibble.Value && (AdvSimd.IsSupported || PackedSimd.IsSuppor
 24
 217525            if (TUniqueLowNibble.Value)
 26            {
 31327                IndexOfAnyAsciiSearcher.ComputeUniqueLowNibbleState(values, out _state);
 28            }
 29            else
 30            {
 186231                IndexOfAnyAsciiSearcher.ComputeAsciiState(values, out _state);
 32            }
 186233        }
 34
 35        internal override byte[] GetValues() =>
 036            _state.Lookup.GetByteValues();
 37
 38        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 39        internal override bool ContainsCore(byte value) =>
 58539940            _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) =>
 652547            IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TUniqueLowNibble>(
 652548                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) =>
 652555            IndexOfAnyAsciiSearcher.IndexOfAny<IndexOfAnyAsciiSearcher.Negate, TUniqueLowNibble>(
 652556                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) =>
 435063            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, TUniqueLowNibble>(
 435064                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) =>
 435071            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate, TUniqueLowNibble>(
 435072                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) =>
 217579            IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.DontNegate, TUniqueLowNibble>(
 217580                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) =>
 217587            IndexOfAnyAsciiSearcher.ContainsAny<IndexOfAnyAsciiSearcher.Negate, TUniqueLowNibble>(
 217588                ref MemoryMarshal.GetReference(span), span.Length, ref _state);
 89    }
 90}