Commit 4e02504f5232e38d116830aaf25bcea4d5123a45

Carlos Martín Nieto 2011-03-29T12:10:30

Move config to support the new hash code The hashes have been copied from the references code Signed-off-by: Carlos Martín Nieto <cmn@elego.de>

diff --git a/src/config.c b/src/config.c
index f496202..852bcd3 100644
--- a/src/config.c
+++ b/src/config.c
@@ -35,18 +35,17 @@
  ***********************/
 static int config_parse(git_config *cfg_file);
 static int parse_variable(git_config *cfg, const char *section_name, const char *line);
-uint32_t config_table_hash(const void *key)
-{
-	const char *var_name = (char *)key;
-	return git__hash(key, strlen(var_name), 0x5273eae3);
-}
 
-int config_table_haskey(void *object, const void *key)
+uint32_t config_table_hash(const void *key, int hash_id)
 {
-	git_config_var *var = (git_config_var *)object;
-	const char *var_name = (const char *)key;
+	static uint32_t hash_seeds[GIT_HASHTABLE_HASHES] = {
+		2147483647,
+		0x5d20bb23,
+		0x7daaab3c
+	};
 
-	return (strcmp(var->name, var_name) == 0);
+	const char *var_name = (const char *)key;
+	return git__hash(key, strlen(var_name), hash_seeds[hash_id]);
 }
 
 int git_config_open(git_config **cfg_out, const char *path)
@@ -68,7 +67,8 @@ int git_config_open(git_config **cfg_out, const char *path)
 		goto cleanup;
 	}
 
-	cfg->vars = git_hashtable_alloc(16, config_table_hash, config_table_haskey);
+	cfg->vars = git_hashtable_alloc(16, config_table_hash,
+	                                (git_hash_keyeq_ptr) strcmp);
 	if (cfg->vars == NULL){
 		error = GIT_ENOMEM;
 		goto cleanup;