From 8c611f64bd83d1127448a1ac27d63b04242267d9 Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Tue, 10 Nov 2020 19:54:13 +0100 Subject: [PATCH] nieco viac --- cv6/a_station.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index afe4ffa..dc6eb1b 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -27,13 +27,13 @@ void destroy_station(struct station* station){ } int select_track(struct station* station, const char* target){ - unsigned long hash=0; - - for(int i=0;target[i]!='\0';i++){ - hash= target[i] + (hash << 6) + (hash <<16)-hash; - } - hash = hash%station->track_count; - return hash; + unsigned long hash = 0; + int c; + unsigned char *str; + while (c = *str++) + hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + + return hash; /* int i,len; for(hash = i = 0; i <'\0' ; ++i) {