From 1aa26da9547caaa99cf76ad28e1c609a75a3f554 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 18 Jan 2014 03:04:48 +0100 Subject: [PATCH] Reduce collisions in the mlt_properties hash function. --- src/framework/mlt_properties.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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. -- 2.39.2