different hash algorithm cv6
This commit is contained in:
parent
2b1ee9eadd
commit
699accb1f1
@ -34,14 +34,15 @@ void destroy_station(struct station* station)
|
||||
|
||||
int select_track(struct station* station, const char* target)
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
int prime = 36;
|
||||
//DJB2 hash
|
||||
unsigned int hash = 5381;
|
||||
int c;
|
||||
|
||||
for (size_t i = 0; i < strlen(target); i++)
|
||||
while ((c = *target++))
|
||||
{
|
||||
hash = hash * prime + (unsigned char)target[i];
|
||||
hash = hash * 33 + c;
|
||||
}
|
||||
|
||||
|
||||
return hash % station->track_count;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user