Alexandre Julliard : makedep: Make the filename hashing more efficient.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 1 10:44:06 CST 2016


Module: wine
Branch: master
Commit: bf6db74f85d4a6bbf2ef3f2ce90162382c4fc71f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bf6db74f85d4a6bbf2ef3f2ce90162382c4fc71f

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Mar  1 17:20:33 2016 +0900

makedep: Make the filename hashing more efficient.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/makedep.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/makedep.c b/tools/makedep.c
index adb8a40..298ec04 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -109,7 +109,7 @@ static const struct
     { FLAG_IDL_HEADER,     ".h" }
 };
 
-#define HASH_SIZE 137
+#define HASH_SIZE 997
 
 static struct list files[HASH_SIZE];
 
@@ -728,8 +728,9 @@ static char *get_line( FILE *file )
  */
 static unsigned int hash_filename( const char *name )
 {
-    unsigned int ret = 0;
-    while (*name) ret = (ret << 7) + (ret << 3) + *name++;
+    /* FNV-1 hash */
+    unsigned int ret = 2166136261;
+    while (*name) ret = (ret * 16777619) ^ *name++;
     return ret % HASH_SIZE;
 }
 
@@ -742,7 +743,6 @@ static struct file *add_file( const char *name )
     struct file *file = xmalloc( sizeof(*file) );
     memset( file, 0, sizeof(*file) );
     file->name = xstrdup( name );
-    list_add_tail( &files[hash_filename( name )], &file->entry );
     return file;
 }
 
@@ -1198,6 +1198,7 @@ static struct file *load_file( const char *name )
     if (!(f = fopen( name, "r" ))) return NULL;
 
     file = add_file( name );
+    list_add_tail( &files[hash], &file->entry );
     input_file_name = file->name;
     input_line = 0;
 




More information about the wine-cvs mailing list