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

Method calcSubHash

src/String.cpp:928–972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

926#endif
927
928unsigned int String::calcSubHash(int start, int inLen) const
929{
930 unsigned int result = 0;
931 #ifdef HX_SMART_STRINGS
932 if (isUTF16Encoded())
933 {
934 const char16_t *w = __w + start;
935 for(int i=0;i<inLen;i++)
936 {
937 int c = w[i];
938 if( c <= 0x7F )
939 {
940 ADD_HASH(c);
941 }
942 else if( c <= 0x7FF )
943 {
944 ADD_HASH(0xC0 | (c >> 6));
945 ADD_HASH(0x80 | (c & 63));
946 }
947 else if( c <= 0xFFFF )
948 {
949 ADD_HASH(0xE0 | (c >> 12));
950 ADD_HASH(0x80 | ((c >> 6) & 63));
951 ADD_HASH(0x80 | (c & 63));
952 }
953 else
954 {
955 ADD_HASH(0xF0 | (c >> 18));
956 ADD_HASH(0x80 | ((c >> 12) & 63));
957 ADD_HASH(0x80 | ((c >> 6) & 63) );
958 ADD_HASH(0x80 | (c & 63) );
959 }
960 }
961 }
962 else
963 #endif
964 {
965 const unsigned char *s = (const unsigned char *)__s + start;
966 for(int i=0;i<inLen;i++)
967 result = result*223 + s[i];
968 }
969
970 return result;
971
972}
973
974unsigned int String::calcHash() const
975{

Callers 1

__string_hash_map_substrFunction · 0.80

Calls 1

isUTF16EncodedFunction · 0.85

Tested by

no test coverage detected