From 87571c3f71ba41d89eef5202f8589daa26f984ca Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Oct 2019 23:30:38 +0000 Subject: 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 Reviewed-by: Derrick Stolee Signed-off-by: Junio C Hamano --- blame.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'blame.c') diff --git a/blame.c b/blame.c index aa46c7ec52..3d8accf902 100644 --- a/blame.c +++ b/blame.c @@ -450,9 +450,9 @@ static int fingerprint_similarity(struct fingerprint *a, struct fingerprint *b) struct hashmap_iter iter; const struct fingerprint_entry *entry_a, *entry_b; - hashmap_iter_init(&b->map, &iter); - - while ((entry_b = hashmap_iter_next(&iter))) { + hashmap_for_each_entry(&b->map, &iter, entry_b, + const struct fingerprint_entry, + entry /* member name */) { entry_a = hashmap_get_entry(&a->map, entry_b, NULL, struct fingerprint_entry, entry); if (entry_a) { @@ -473,7 +473,9 @@ static void fingerprint_subtract(struct fingerprint *a, struct fingerprint *b) hashmap_iter_init(&b->map, &iter); - while ((entry_b = hashmap_iter_next(&iter))) { + hashmap_for_each_entry(&b->map, &iter, entry_b, + const struct fingerprint_entry, + entry /* member name */) { entry_a = hashmap_get_entry(&a->map, entry_b, NULL, struct fingerprint_entry, entry); if (entry_a) { -- cgit v1.2.3