diff options
| author | Carlos Martín Nieto <cmn@elego.de> | 2011-03-29 12:10:30 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@elego.de> | 2011-03-29 12:17:29 +0200 |
| commit | 4e02504f5232e38d116830aaf25bcea4d5123a45 (patch) | |
| tree | c1cead9bfcc17139814e3c79d468f3edbfe7e8f3 | |
| parent | 3b4835c25a41781d27a667dbd02ff03d54d221b9 (diff) | |
| download | libgit2-4e02504f5232e38d116830aaf25bcea4d5123a45.tar.gz | |
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>
| -rw-r--r-- | src/config.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c index f49620246..852bcd3b1 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; |
