Commit bf6db74f authored by Alexandre Julliard's avatar Alexandre Julliard

makedep: Make the filename hashing more efficient.

parent 850df9d5
...@@ -109,7 +109,7 @@ static const struct ...@@ -109,7 +109,7 @@ static const struct
{ FLAG_IDL_HEADER, ".h" } { FLAG_IDL_HEADER, ".h" }
}; };
#define HASH_SIZE 137 #define HASH_SIZE 997
static struct list files[HASH_SIZE]; static struct list files[HASH_SIZE];
...@@ -728,8 +728,9 @@ static char *get_line( FILE *file ) ...@@ -728,8 +728,9 @@ static char *get_line( FILE *file )
*/ */
static unsigned int hash_filename( const char *name ) static unsigned int hash_filename( const char *name )
{ {
unsigned int ret = 0; /* FNV-1 hash */
while (*name) ret = (ret << 7) + (ret << 3) + *name++; unsigned int ret = 2166136261;
while (*name) ret = (ret * 16777619) ^ *name++;
return ret % HASH_SIZE; return ret % HASH_SIZE;
} }
...@@ -742,7 +743,6 @@ static struct file *add_file( const char *name ) ...@@ -742,7 +743,6 @@ static struct file *add_file( const char *name )
struct file *file = xmalloc( sizeof(*file) ); struct file *file = xmalloc( sizeof(*file) );
memset( file, 0, sizeof(*file) ); memset( file, 0, sizeof(*file) );
file->name = xstrdup( name ); file->name = xstrdup( name );
list_add_tail( &files[hash_filename( name )], &file->entry );
return file; return file;
} }
...@@ -1198,6 +1198,7 @@ static struct file *load_file( const char *name ) ...@@ -1198,6 +1198,7 @@ static struct file *load_file( const char *name )
if (!(f = fopen( name, "r" ))) return NULL; if (!(f = fopen( name, "r" ))) return NULL;
file = add_file( name ); file = add_file( name );
list_add_tail( &files[hash], &file->entry );
input_file_name = file->name; input_file_name = file->name;
input_line = 0; input_line = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment