< Summary

Information
Class: Trailblazer.Pathing.PathQueryBatchItem
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Query/PathQueryBatch.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 67
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%11100%
GetLogicalRetainedBytes(...)100%11100%
AddStringPayload(...)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    {
 2617        StableOrdinal = stableOrdinal;
 2618        Query = query;
 2619    }
 20
 21    internal long StableOrdinal { get; }
 22
 23    internal PathQuery Query { get; }
 24
 25    internal static long GetLogicalRetainedBytes(PathQuery query)
 26    {
 47927        long retainedBytes = LogicalRetainedBytes;
 47928        retainedBytes = AddStringPayload(retainedBytes, query.Start.MapId);
 47929        retainedBytes = AddStringPayload(retainedBytes, query.End.MapId);
 47930        return AddStringPayload(retainedBytes, query.AreaPolicy.PolicyId);
 31    }
 32
 33    private static long AddStringPayload(long bytes, string? value) =>
 143734        value == null
 143735            ? bytes
 143736            : 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    {
 44        SwiftThrowHelper.ThrowIfNull(items, nameof(items));
 45        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 46            count < 0 || count > items.Length,
 47            count,
 48            nameof(count));
 49        Items = items;
 50        Count = count;
 51    }
 52
 53    internal PathQueryBatchItem[] Items { get; }
 54
 55    internal int Count { get; }
 56
 57    internal long GetLogicalRetainedBytes()
 58    {
 59        long retainedBytes = 0;
 60        for (int i = 0; i < Count; i++)
 61        {
 62            retainedBytes += PathQueryBatchItem.GetLogicalRetainedBytes(
 63                Items[i].Query);
 64        }
 65        return retainedBytes;
 66    }
 67}