< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 68
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%440%
GetValues()100%110%
ContainsCore(...)0%220%
IndexOfAny(...)100%110%
IndexOfAnyExcept(...)100%110%
LastIndexOfAny(...)100%110%
LastIndexOfAnyExcept(...)100%110%

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
 021        public Any2CharPackedIgnoreCaseSearchValues(char value0, char value1)
 22        {
 023            Debug.Assert((value0 | 0x20) == value0 && char.IsAscii(value0));
 024            Debug.Assert((value1 | 0x20) == value1 && char.IsAscii(value1));
 25
 026            (_e0, _e1) = (value0, value1);
 027            (_uint0, _uint1) = (value0, value1);
 028            IndexOfAnyAsciiSearcher.ComputeAsciiState([(char)(_e0 & ~0x20), _e0, (char)(_e1 & ~0x20), _e1], out _state);
 029        }
 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        {
 037            uint lowerCase = (uint)(value | 0x20);
 038            return lowerCase == _uint0 || lowerCase == _uint1;
 39        }
 40
 41        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 42        [CompExactlyDependsOn(typeof(Sse2))]
 43        internal override int IndexOfAny(ReadOnlySpan<char> span) =>
 044            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) =>
 049            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) =>
 056            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate, IndexOfAnyAsciiSearcher.Default, 
 057                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) =>
 064            IndexOfAnyAsciiSearcher.LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate, IndexOfAnyAsciiSearcher.Default, Sear
 065                ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
 66    }
 67}
 68