MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / calcHash

Method calcHash

src/String.cpp:974–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

972}
973
974unsigned int String::calcHash() const
975{
976 unsigned int result = 0;
977 #ifdef HX_SMART_STRINGS
978 if (isUTF16Encoded())
979 {
980 for(int i=0;i<length;i++)
981 {
982 int c = __w[i];
983 if( c <= 0x7F )
984 {
985 ADD_HASH(c);
986 }
987 else if( c <= 0x7FF )
988 {
989 ADD_HASH(0xC0 | (c >> 6));
990 ADD_HASH(0x80 | (c & 63));
991 }
992 else if( c <= 0xFFFF )
993 {
994 ADD_HASH(0xE0 | (c >> 12));
995 ADD_HASH(0x80 | ((c >> 6) & 63));
996 ADD_HASH(0x80 | (c & 63));
997 }
998 else
999 {
1000 ADD_HASH(0xF0 | (c >> 18));
1001 ADD_HASH(0x80 | ((c >> 12) & 63));
1002 ADD_HASH(0x80 | ((c >> 6) & 63) );
1003 ADD_HASH(0x80 | (c & 63) );
1004 }
1005 }
1006 }
1007 else
1008 #endif
1009 for(int i=0;i<length;i++)
1010 result = result*223 + ((unsigned char *)__s)[i];
1011
1012 return result;
1013}
1014
1015
1016

Callers 1

fixHashPerm16Function · 0.80

Calls 1

isUTF16EncodedFunction · 0.85

Tested by

no test coverage detected