< Summary

Line coverage
91%
Covered lines: 11
Uncovered lines: 1
Coverable lines: 12
Total lines: 53
Line coverage: 91.6%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
GetValues()100%110%
ContainsCore(...)100%11100%
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/Any1CharPackedIgnoreCaseSearchValues.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.X86;
 8
 9namespace System.Buffers
 10{
 11    internal sealed class Any1CharPackedIgnoreCaseSearchValues : SearchValues<char>
 12    {
 13        // While this most commonly applies to ASCII letters, it also works for other values that differ by 0x20 (e.g. "
 14        // _lowerCase is therefore not necessarily a lower case ASCII letter, but just the higher value (the one with th
 15        private readonly char _lowerCase, _upperCase;
 16        private readonly uint _lowerCaseUint;
 17
 15918        public Any1CharPackedIgnoreCaseSearchValues(char value)
 19        {
 15920            Debug.Assert((value | 0x20) == value);
 21
 15922            _lowerCase = value;
 15923            _upperCase = (char)(value & ~0x20);
 15924            _lowerCaseUint = value;
 15925        }
 26
 27        internal override char[] GetValues() =>
 028            [_upperCase, _lowerCase];
 29
 30        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 31        internal override bool ContainsCore(char value) =>
 2421032            (uint)(value | 0x20) == _lowerCaseUint;
 33
 34        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 35        [CompExactlyDependsOn(typeof(Sse2))]
 36        internal override int IndexOfAny(ReadOnlySpan<char> span) =>
 63637            PackedSpanHelpers.IndexOfAnyIgnoreCase(ref MemoryMarshal.GetReference(span), _lowerCase, span.Length);
 38
 39        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 40        [CompExactlyDependsOn(typeof(Sse2))]
 41        internal override int IndexOfAnyExcept(ReadOnlySpan<char> span) =>
 63642            PackedSpanHelpers.IndexOfAnyExceptIgnoreCase(ref MemoryMarshal.GetReference(span), _lowerCase, span.Length);
 43
 44        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 45        internal override int LastIndexOfAny(ReadOnlySpan<char> span) =>
 31846            span.LastIndexOfAny(_lowerCase, _upperCase);
 47
 48        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 49        internal override int LastIndexOfAnyExcept(ReadOnlySpan<char> span) =>
 31850            span.LastIndexOfAnyExcept(_lowerCase, _upperCase);
 51    }
 52}
 53