Development Merge 2025.10.18 #4
							
								
								
									
										27
									
								
								Engine.Systems/Network/TypeHasher.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Engine.Systems/Network/TypeHasher.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
namespace Engine.Systems.Network;
 | 
			
		||||
 | 
			
		||||
public static class TypeHasher<T>
 | 
			
		||||
{
 | 
			
		||||
    private static long _fnv1a = 0;
 | 
			
		||||
    public static long FNV1a
 | 
			
		||||
    {
 | 
			
		||||
        get
 | 
			
		||||
        {
 | 
			
		||||
            if (_fnv1a == 0)
 | 
			
		||||
                unchecked
 | 
			
		||||
                {
 | 
			
		||||
                    const long fnvPrime = 1099511628211;
 | 
			
		||||
                    _fnv1a = 1469598103934665603;
 | 
			
		||||
 | 
			
		||||
                    string typeName = typeof(T).FullName ?? typeof(T).Name;
 | 
			
		||||
                    foreach (char c in typeName)
 | 
			
		||||
                    {
 | 
			
		||||
                        _fnv1a ^= c;
 | 
			
		||||
                        _fnv1a *= fnvPrime;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            return _fnv1a;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user