Merge branch 'sb/hashmap-customize-comparison'
Update the hashmap API so that data to customize the behaviour of the comparison function can be specified at the time a hashmap is initialized. * sb/hashmap-customize-comparison: hashmap: migrate documentation from Documentation/technical into header patch-ids.c: use hashmap correctly hashmap.h: compare function has access to a data field
This commit is contained in:
@ -33,17 +33,19 @@ enum lookup_type {
|
||||
lookup_path
|
||||
};
|
||||
|
||||
static int config_path_cmp(const struct submodule_entry *a,
|
||||
static int config_path_cmp(const void *unused_cmp_data,
|
||||
const struct submodule_entry *a,
|
||||
const struct submodule_entry *b,
|
||||
const void *unused)
|
||||
const void *unused_keydata)
|
||||
{
|
||||
return strcmp(a->config->path, b->config->path) ||
|
||||
hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
|
||||
}
|
||||
|
||||
static int config_name_cmp(const struct submodule_entry *a,
|
||||
static int config_name_cmp(const void *unused_cmp_data,
|
||||
const struct submodule_entry *a,
|
||||
const struct submodule_entry *b,
|
||||
const void *unused)
|
||||
const void *unused_keydata)
|
||||
{
|
||||
return strcmp(a->config->name, b->config->name) ||
|
||||
hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
|
||||
@ -56,8 +58,8 @@ static struct submodule_cache *submodule_cache_alloc(void)
|
||||
|
||||
static void submodule_cache_init(struct submodule_cache *cache)
|
||||
{
|
||||
hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, 0);
|
||||
hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, 0);
|
||||
hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, NULL, 0);
|
||||
hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, NULL, 0);
|
||||
cache->initialized = 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user