< Summary

Line coverage
83%
Covered lines: 10
Uncovered lines: 2
Coverable lines: 12
Total lines: 51
Line coverage: 83.3%
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/Any1SearchValues.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 Any1SearchValues<T, TImpl> : SearchValues<T>
 12        where T : struct, IEquatable<T>
 13        where TImpl : struct, INumber<TImpl>
 14    {
 15        private readonly TImpl _e0;
 16
 106917        public unsafe Any1SearchValues(ReadOnlySpan<TImpl> values)
 18        {
 106919            Debug.Assert(sizeof(T) == sizeof(TImpl));
 106920            Debug.Assert(values.Length == 1);
 106921            _e0 = values[0];
 106922        }
 23
 24        internal override unsafe T[] GetValues()
 25        {
 026            TImpl e0 = _e0;
 027            return [*(T*)&e0];
 28        }
 29
 30        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 31        internal override unsafe bool ContainsCore(T value) =>
 22449132            *(TImpl*)&value == _e0;
 33
 34        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 35        internal override int IndexOfAny(ReadOnlySpan<T> span) =>
 427636            SpanHelpers.NonPackedIndexOfValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref Memo
 37
 38        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 39        internal override int IndexOfAnyExcept(ReadOnlySpan<T> span) =>
 427640            SpanHelpers.NonPackedIndexOfValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMa
 41
 42        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 43        internal override int LastIndexOfAny(ReadOnlySpan<T> span) =>
 213844            SpanHelpers.LastIndexOfValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Le
 45
 46        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 47        internal override int LastIndexOfAnyExcept(ReadOnlySpan<T> span) =>
 213848            SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0
 49    }
 50}
 51