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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
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;