< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 51
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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(...)100%110%
GetValues()100%110%
ContainsCore(...)0%440%
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/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
 017        public unsafe Any3SearchValues(ReadOnlySpan<TImpl> values)
 18        {
 019            Debug.Assert(sizeof(T) == sizeof(TImpl));
 020            Debug.Assert(values.Length == 3);
 021            (_e0, _e1, _e2) = (values[0], values[1], values[2]);
 022        }
 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) =>
 032            *(TImpl*)&value == _e0 || *(TImpl*)&value == _e1 || *(TImpl*)&value == _e2;
 33
 34        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 35        internal override int IndexOfAny(ReadOnlySpan<T> span) =>
 036            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) =>
 040            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) =>
 044            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) =>
 048            SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0
 49    }
 50}
 51