| 926 | #endif |
| 927 | |
| 928 | unsigned 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 | |
| 974 | unsigned int String::calcHash() const |
| 975 | { |
no test coverage detected