< Summary

Information
Class: DeltaSharp.Util.Hashtable.Hash
Assembly: DeltaSharp
File(s): /home/runner/work/DeltaSharp/DeltaSharp/src/DeltaSharp/Util/Hashtable/Hash.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 44
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TableSize(...)75%44100%
TableSize(...)100%11100%
Hash64(...)100%11100%

File(s)

/home/runner/work/DeltaSharp/DeltaSharp/src/DeltaSharp/Util/Hashtable/Hash.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Numerics;
 5using System.Runtime.CompilerServices;
 6using System.Runtime.InteropServices;
 7using System.Text;
 8using System.Threading.Tasks;
 9
 10namespace DeltaSharp.Util.Hashtable;
 11
 12internal readonly ref struct Hash
 13{
 14    public static int TableSize(int blockCount)
 15    {
 16#if NETSTANDARD2_0
 60317        int size = 1;
 631318        while (size < blockCount)
 571019            size <<= 1;
 60320        return blockCount == 0 ? 0 : size;
 21#else
 241222        return (int)BitOperations.RoundUpToPowerOf2((uint)blockCount);
 23#endif
 24    }
 25
 26    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 27    public static ulong Hash64(ulong x)
 28    {
 29        //  SplitableRandom
 30        // https://nullprogram.com/blog/2018/07/31/
 31        unchecked
 32        {
 18152642033            x ^= x >> 30;
 18152642034            x *= 0xbf58476d1ce4e5b9U;
 18152642035            x ^= x >> 27;
 18152642036            x *= 0x94d049bb133111ebU;
 18152642037            x ^= x >> 31;
 38
 18152642039            return x;
 40        }
 41
 42    }
 43
 44}