diff options
author | Eric Wong <e@80x24.org> | 2019-10-06 23:30:38 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-07 10:20:11 +0900 |
commit | 87571c3f71ba41d89eef5202f8589daa26f984ca (patch) | |
tree | d3b072917efce49f3f95d7d48763a8dfc83ef211 /submodule-config.c | |
parent | 939af16eac1608766273d3971598dbcc4fe09928 (diff) | |
download | git-87571c3f71ba41d89eef5202f8589daa26f984ca.tar.gz |
hashmap: use *_entry APIs for iteration
Inspired by list_for_each_entry in the Linux kernel.
Once again, these are somewhat compromised usability-wise
by compilers lacking __typeof__ support.
Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule-config.c')
-rw-r--r-- | submodule-config.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/submodule-config.c b/submodule-config.c index 5463729ab8..5319933e1d 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -99,8 +99,8 @@ static void submodule_cache_clear(struct submodule_cache *cache) * allocation of struct submodule entries. Each is allocated by * their .gitmodules blob sha1 and submodule name. */ - hashmap_iter_init(&cache->for_name, &iter); - while ((entry = hashmap_iter_next(&iter))) + hashmap_for_each_entry(&cache->for_name, &iter, entry, + struct submodule_entry, ent /* member name */) free_one_config(entry); hashmap_free(&cache->for_path, 1); @@ -556,7 +556,9 @@ static const struct submodule *config_from(struct submodule_cache *cache, struct hashmap_iter iter; struct submodule_entry *entry; - entry = hashmap_iter_first(&cache->for_name, &iter); + entry = hashmap_iter_first_entry(&cache->for_name, &iter, + struct submodule_entry, + ent /* member name */); if (!entry) return NULL; return entry->config; |