MCPcopy Create free account
hub / github.com/documentdb/documentdb / djb2

Function djb2

pg_documentdb_core/src/collation/collation.c:865–875  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

863 * the functionality will not be broken, we will just generate a few more cache entries
864 */
865static unsigned long
866djb2(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/*

Callers 1

LookupUCollatorCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected