< Summary

Line coverage
93%
Covered lines: 15
Uncovered lines: 1
Coverable lines: 16
Total lines: 68
Line coverage: 93.7%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any2CharPackedIgnoreCaseSearchValues.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;
 10
 11namespace System.Buffers
 12{
 13    internal sealed class Any2CharPackedIgnoreCaseSearchValues : SearchValues<char>
 14    {
 15        // While this most commonly applies to ASCII letters, it also works for other values that differ by 0x20 (e.g. "
 16        // _e0 and _e1 are therefore not necessarily lower case ASCII letters, but just the higher values (the ones with
 17        private readonly char _e0, _e1;
 18        private readonly uint _uint0, _uint1;
 19        private IndexOfAnyAsciiSearcher.AsciiState _state;
 20
 36021        public Any2CharPackedIgnoreCaseSearchValues(char value0, char value1)
 22        {
 36023            Debug.Assert((value0 | 0x20) == value0 && char.IsAscii(value0));
 36024            Debug.Assert((value1 | 0x20) == value1 && char.IsAscii(value1));
 25
 36026            (_e0, _e1) = (value0, value1);
 36027            (_uint0, _uint1) = (value0, value1);
 36028            IndexOfAnyAsciiSearcher.ComputeAsciiState([(char)(_e0 & ~0x20), _e0, (char)(_e1 & ~0x20), _e1], out _state);
 36029        }
 30
 31        internal override char[] GetValues() =>
 032            [(char)(_e0 & ~0x20), _e0, (char)(_e1 & ~0x20), _e1];
 33
 34        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 35        internal override bool ContainsCore(char value)
 36        {
 4075437            uint lowerCase = (uint)(value | 0x20);
 4075438            return lowerCase == _uint0 || lowerCase == _uint1;
 39        }
 40
 41        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 42        [CompExactlyDependsOn(typeof(Sse2))]
 43        internal override int IndexOfAny(ReadOnlySpan<char> span) =>
 144044            PackedSpanHelpers.IndexOfAnyIgnoreCase(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length);
 45
 46        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 47        [CompExactlyDependsOn(typeof(Sse2))]
 48        internal override int IndexOfAnyExcept(ReadOnlySpan<char> span) =>
 144049            PackedSpanHelpers.IndexOfAnyExceptIgnoreCase(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length);
 50
 51        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 52        [CompExactlyDependsOn(typeof(Ssse3))]
 53        [CompExactlyDependsOn(typeof(AdvSimd))]
 54        [CompExactlyDependsOn(typeof(PackedSimd))]
 55        internal override int LastIndexOfAny(ReadOnlySpan<char> span) =>
 72056            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, IndexOfAnyAsciiSearcher.Default, 
 72057                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 58
 59        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 60        [CompExactlyDependsOn(typeof(Ssse3))]
 61        [CompExactlyDependsOn(typeof(AdvSimd))]
 62        [CompExactlyDependsOn(typeof(PackedSimd))]
 63        internal override int LastIndexOfAnyExcept(ReadOnlySpan<char> span) =>
 72064            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate, IndexOfAnyAsciiSearcher.Default, Sear
 72065                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 66    }
 67}
 68