* Well known hash function to efficiently calculate hash of a string. While it may have collisions it's unlikely in our case * where the hash function is used to generate hash code for limited number of collation strings. Even if there is collision, * the functionality will not be broken, we will just generate a few more cache entries */
| 863 | * the functionality will not be broken, we will just generate a few more cache entries |
| 864 | */ |
| 865 | static unsigned long |
| 866 | djb2(const char *str) |
| 867 | { |
| 868 | unsigned long hash = 5381; |
| 869 | int c; |
| 870 | while ((c = *str++)) |
| 871 | { |
| 872 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ |
| 873 | } |
| 874 | return hash; |
| 875 | } |
| 876 | |
| 877 | |
| 878 | /* |
no outgoing calls
no test coverage detected