NOTE: @size must be 2^N, otherwise there will be gaps in the output range */
| 44 | |
| 45 | /* NOTE: @size must be 2^N, otherwise there will be gaps in the output range */ |
| 46 | static inline unsigned int core_hash(const str *s1, const str *s2, const unsigned int size) |
| 47 | { |
| 48 | char *p, *end; |
| 49 | register unsigned v; |
| 50 | register unsigned h; |
| 51 | |
| 52 | h=0; |
| 53 | |
| 54 | end=s1->s+s1->len; |
| 55 | for ( p=s1->s ; p<=(end-4) ; p+=4 ){ |
| 56 | v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3]; |
| 57 | ch_h_inc; |
| 58 | } |
| 59 | v=0; |
| 60 | for (; p<end ; p++){ v<<=8; v+=*p;} |
| 61 | ch_h_inc; |
| 62 | |
| 63 | if (s2) { |
| 64 | end=s2->s+s2->len; |
| 65 | for (p=s2->s; p<=(end-4); p+=4){ |
| 66 | v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3]; |
| 67 | ch_h_inc; |
| 68 | } |
| 69 | v=0; |
| 70 | for (; p<end ; p++){ v<<=8; v+=*p;} |
| 71 | ch_h_inc; |
| 72 | } |
| 73 | h=((h)+(h>>11))+((h>>13)+(h>>23)); |
| 74 | return size?((h)&(size-1)):h; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | static inline unsigned int core_case_hash( str *s1, str *s2, unsigned int size) |
no outgoing calls
no test coverage detected