Source/NFX/Glue/Protocol/Specifiers.cs
/// <summary>
/// Converts string identifier into uint64 stable hash that does not depend on a platform.
/// This functions optimized for hashing identifiers/type names
/// </summary>
Converts string identifier into uint64 stable hash that does not depend on a platform.
This functions optimized for hashing identifiers/type names
Converts string identifier into uint64 stable hash that does not depend on a platform . This functions optimized for hashing identifiers / type names
public static ulong StringIDHash(string id)
        {
            if (id==null) return 0;
            var sl = id.Length;
            if (sl==0) return 0;
            ulong result = (ulong)(sl % 251) << 56;
            ulong hash2 = 0;
            for(int i=id.Length-1, cnt=0; cnt<sizeof(ulong)-1 && i>=0; i--,cnt++)
            {
              if (cnt>0) hash2 <<= 8;
              hash2 |= (byte)id[i];
            }
            result |= (ulong)hash2;
            return result;
        }
public static ulong StringIDHash ( string id ) { if ( id == null ) return 0 ; var sl = id . Length ; if ( sl == 0 ) return 0 ; ulong result = ( ulong ) ( sl % 251 ) << 56 ; ulong hash2 = 0 ; for ( int i = id . Length - 1 , cnt = 0 ; cnt < sizeof ( ulong ) - 1 && i >= 0 ; i -- , cnt ++ ) { if ( cnt > 0 ) hash2 <<= 8 ; hash2 |= ( byte ) id [ i ] ; } result |= ( ulong ) hash2 ; return result ; }
Converts string identifier into uint64 stable hash that does not depend on a platform.
Converts string identifier into uint64 stable hash that does not depend on a platform .
//64-8
id
string