]> git.sesse.net Git - mlt/commitdiff
Reduce collisions in the mlt_properties hash function.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 18 Jan 2014 02:04:48 +0000 (03:04 +0100)
committerDan Dennedy <dan@dennedy.org>
Sun, 26 Jan 2014 20:39:46 +0000 (12:39 -0800)
src/framework/mlt_properties.c

index c28af8fc514c2043f574b993b9945683cee39b84..2a37ab4d9f84613752bb5288874114d781dc5aa6 100644 (file)
@@ -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.