< Summary

Information
Class: Trailblazer.Pathing.PathQueryBatch
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Query/PathQueryBatch.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 67
Line coverage: 100%
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 Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%22100%
GetLogicalRetainedBytes()100%22100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Query/PathQueryBatch.cs

#LineLine coverage
 1//=======================================================================
 2// PathQueryBatch.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8namespace Trailblazer.Pathing;
 9
 10/// <summary>Pairs one query with its caller-owned stable operation ordinal.</summary>
 11internal readonly struct PathQueryBatchItem
 12{
 13    internal const long LogicalRetainedBytes = 248L;
 14
 15    internal PathQueryBatchItem(long stableOrdinal, PathQuery query)
 16    {
 17        StableOrdinal = stableOrdinal;
 18        Query = query;
 19    }
 20
 21    internal long StableOrdinal { get; }
 22
 23    internal PathQuery Query { get; }
 24
 25    internal static long GetLogicalRetainedBytes(PathQuery query)
 26    {
 27        long retainedBytes = LogicalRetainedBytes;
 28        retainedBytes = AddStringPayload(retainedBytes, query.Start.MapId);
 29        retainedBytes = AddStringPayload(retainedBytes, query.End.MapId);
 30        return AddStringPayload(retainedBytes, query.AreaPolicy.PolicyId);
 31    }
 32
 33    private static long AddStringPayload(long bytes, string? value) =>
 34        value == null
 35            ? bytes
 36            : bytes + ((long)value.Length * sizeof(char));
 37}
 38
 39/// <summary>Describes a caller-owned prefix of immutable path queries.</summary>
 40internal readonly struct PathQueryBatch
 41{
 42    internal PathQueryBatch(PathQueryBatchItem[] items, int count)
 43    {
 1944        SwiftThrowHelper.ThrowIfNull(items, nameof(items));
 1845        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 1846            count < 0 || count > items.Length,
 1847            count,
 1848            nameof(count));
 1649        Items = items;
 1650        Count = count;
 1651    }
 52
 53    internal PathQueryBatchItem[] Items { get; }
 54
 55    internal int Count { get; }
 56
 57    internal long GetLogicalRetainedBytes()
 58    {
 1259        long retainedBytes = 0;
 7260        for (int i = 0; i < Count; i++)
 61        {
 2462            retainedBytes += PathQueryBatchItem.GetLogicalRetainedBytes(
 2463                Items[i].Query);
 64        }
 1265        return retainedBytes;
 66    }
 67}