< Summary

Line coverage
83%
Covered lines: 10
Uncovered lines: 2
Coverable lines: 12
Total lines: 51
Line coverage: 83.3%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
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%44100%
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/Any3SearchValues.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.Numerics;
 6using System.Runtime.CompilerServices;
 7using System.Runtime.InteropServices;
 8
 9namespace System.Buffers
 10{
 11    internal sealed class Any3SearchValues<T, TImpl> : SearchValues<T>
 12        where T : struct, IEquatable<T>
 13        where TImpl : struct, INumber<TImpl>
 14    {
 15        private readonly TImpl _e0, _e1, _e2;
 16
 87217        public unsafe Any3SearchValues(ReadOnlySpan<TImpl> values)
 18        {
 87219            Debug.Assert(sizeof(T) == sizeof(TImpl));
 87220            Debug.Assert(values.Length == 3);
 87221            (_e0, _e1, _e2) = (values[0], values[1], values[2]);
 87222        }
 23
 24        internal override unsafe T[] GetValues()
 25        {
 026            TImpl e0 = _e0, e1 = _e1, e2 = _e2;
 027            return [*(T*)&e0, *(T*)&e1, *(T*)&e2];
 28        }
 29
 30        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 31        internal override unsafe bool ContainsCore(T value) =>
 20162932            *(TImpl*)&value == _e0 || *(TImpl*)&value == _e1 || *(TImpl*)&value == _e2;
 33
 34        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 35        internal override int IndexOfAny(ReadOnlySpan<T> span) =>
 348836            SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref M
 37
 38        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 39        internal override int IndexOfAnyExcept(ReadOnlySpan<T> span) =>
 348840            SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref Memor
 41
 42        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 43        internal override int LastIndexOfAny(ReadOnlySpan<T> span) =>
 174444            SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1,
 45
 46        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 47        internal override int LastIndexOfAnyExcept(ReadOnlySpan<T> span) =>
 174448            SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0
 49    }
 50}
 51