From: Steinar H. Gunderson Date: Sat, 18 Jan 2014 02:04:48 +0000 (+0100) Subject: Reduce collisions in the mlt_properties hash function. X-Git-Url: https://git.sesse.net/?p=mlt;a=commitdiff_plain;h=1aa26da9547caaa99cf76ad28e1c609a75a3f554 Reduce collisions in the mlt_properties hash function. --- diff --git a/src/framework/mlt_properties.c b/src/framework/mlt_properties.c index c28af8fc..2a37ab4d 100644 --- a/src/framework/mlt_properties.c +++ b/src/framework/mlt_properties.c @@ -328,11 +328,10 @@ int mlt_properties_preset( mlt_properties self, const char *name ) static inline int generate_hash( const char *name ) { - int hash = 0; - int i = 1; + unsigned int hash = 5381; while ( *name ) - hash = ( hash + ( i ++ * ( *name ++ & 31 ) ) ) % 199; - return hash; + hash = hash * 33 + (unsigned int) ( *name ++ ); + return hash % 199; } /** Copy a serializable property to a properties list that is mirroring this one.