< Summary

Information
Class: Lattice.ECS.Serialization.HashCodeUtils
Assembly: Lattice
File(s): /home/runner/work/Sideline/Sideline/godot/scripts/lattice/ECS/Serialization/HashCodeUtils.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 48
Line coverage: 0%
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 Crap Score Cyclomatic complexity Line coverage
CombineHashCodes(...)100%210%
CombineHashCodes(...)100%210%
Int64HashCode(...)100%210%
UInt64HashCode(...)100%210%

File(s)

/home/runner/work/Sideline/Sideline/godot/scripts/lattice/ECS/Serialization/HashCodeUtils.cs

#LineLine coverage
 1// Copyright (c) 2026 Sideline Authors. All rights reserved.
 2// Licensed under GPL-3.0.
 3
 4using System.Runtime.CompilerServices;
 5
 6namespace Lattice.ECS.Serialization
 7{
 8    /// <summary>
 9    /// 哈希码工具类(对齐 FrameSync)
 10    /// </summary>
 11    public static class HashCodeUtils
 12    {
 13        /// <summary>
 14        /// 合并两个哈希码(FrameSync 算法:((a &lt;&lt; 5) + a) ^ b)
 15        /// </summary>
 16        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 17        public static int CombineHashCodes(int a, int b)
 18        {
 019            return ((a << 5) + a) ^ b;
 20        }
 21
 22        /// <summary>
 23        /// 合并三个哈希码
 24        /// </summary>
 25        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 26        public static int CombineHashCodes(int a, int b, int c)
 27        {
 028            int t = ((a << 5) + a) ^ b;
 029            return ((t << 5) + t) ^ c;
 30        }
 31
 32        /// <summary>
 33        /// 计算 long 的哈希码
 34        /// </summary>
 35        public static int Int64HashCode(long value)
 36        {
 037            return (int)value ^ (int)(value >> 32);
 38        }
 39
 40        /// <summary>
 41        /// 计算 ulong 的哈希码(FrameSync 算法:(int)value ^ (int)(value >> 32))
 42        /// </summary>
 43        public static int UInt64HashCode(ulong value)
 44        {
 045            return (int)value ^ (int)(value >> 32);
 46        }
 47    }
 48}