< Summary

Class:Itinero.Network.Tiles.ArrayBaseExtensions
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/ArrayBaseExtensions.cs
Covered lines:15
Uncovered lines:5
Coverable lines:20
Total lines:72
Line coverage:75% (15 of 20)
Covered branches:6
Total branches:8
Branch coverage:75% (6 of 8)
Tag:284_38118444584

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
EnsureMinimumSize(...)100%2100%
EnsureMinimumSize(...)100%2100%
EnsureMinimumSize(...)100%2100%
EnsureMinimumSize(...)0%20%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/ArrayBaseExtensions.cs

#LineLine coverage
 1namespace Itinero.Network.Tiles;
 2
 3internal static class ArrayBaseExtensions
 4{
 5    /// <summary>
 6    /// Increase the native byte array size with a fixed step (but never more) to ensure the given position fits.
 7    /// </summary>
 8    /// <param name="array">The array.</param>
 9    /// <param name="position">The position.</param>
 10    /// <param name="step">The steps to add.</param>
 11    public static void EnsureMinimumSize(ref byte[] array, long position, long step = 16)
 19204712    {
 36601313        if (array.Length > position) return;
 14
 15        // Geometric, floored at step. The fixed-step version here resized once per `step` bytes,
 16        // which is a full Array.Resize each time — quadratic when appending to a tile loaded from
 17        // the cache, because such a tile is sized to exactly its content and has no headroom.
 1808118        var newSize = System.Math.Max(position + 1, array.Length + System.Math.Max(step, array.Length >> 3));
 1808119        System.Array.Resize(ref array, (int)newSize);
 19204720    }
 21
 22    /// <summary>
 23    /// Increase the native int array size with a fixed step (but never more) to ensure the given position fits.
 24    /// </summary>
 25    /// <param name="array">The array.</param>
 26    /// <param name="position">The position.</param>
 27    /// <param name="step">The steps to add.</param>
 28    public static void EnsureMinimumSize(ref int[] array, long position, long step = 16)
 10000529    {
 19994130        if (array.Length > position) return;
 31
 32        // Geometric, floored at step. The fixed-step version here resized once per `step` bytes,
 33        // which is a full Array.Resize each time — quadratic when appending to a tile loaded from
 34        // the cache, because such a tile is sized to exactly its content and has no headroom.
 6935        var newSize = System.Math.Max(position + 1, array.Length + System.Math.Max(step, array.Length >> 3));
 6936        System.Array.Resize(ref array, (int)newSize);
 10000537    }
 38
 39    /// <summary>
 40    /// Increase the native uint array size with a fixed step (but never more) to ensure the given position fits.
 41    /// </summary>
 42    /// <param name="array">The array.</param>
 43    /// <param name="position">The position.</param>
 44    /// <param name="step">The steps to add.</param>
 45    public static void EnsureMinimumSize(ref uint[] array, long position, long step = 16)
 5108246    {
 9579547        if (array.Length > position) return;
 48
 49        // Geometric, floored at step. The fixed-step version here resized once per `step` bytes,
 50        // which is a full Array.Resize each time — quadratic when appending to a tile loaded from
 51        // the cache, because such a tile is sized to exactly its content and has no headroom.
 636952        var newSize = System.Math.Max(position + 1, array.Length + System.Math.Max(step, array.Length >> 3));
 636953        System.Array.Resize(ref array, (int)newSize);
 5108254    }
 55
 56    /// <summary>
 57    /// Increase the native string array size with a fixed step (but never more) to ensure the given position fits.
 58    /// </summary>
 59    /// <param name="array">The array.</param>
 60    /// <param name="position">The position.</param>
 61    /// <param name="step">The steps to add.</param>
 62    public static void EnsureMinimumSize(ref string[] array, long position, long step = 16)
 063    {
 064        if (array.Length > position) return;
 65
 66        // Geometric, floored at step. The fixed-step version here resized once per `step` bytes,
 67        // which is a full Array.Resize each time — quadratic when appending to a tile loaded from
 68        // the cache, because such a tile is sized to exactly its content and has no headroom.
 069        var newSize = System.Math.Max(position + 1, array.Length + System.Math.Max(step, array.Length >> 3));
 070        System.Array.Resize(ref array, (int)newSize);
 071    }
 72}