summaryrefslogtreecommitdiff
path: root/blame.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-10-06 23:30:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-07 01:20:11 (GMT)
commit87571c3f71ba41d89eef5202f8589daa26f984ca (patch)
treed3b072917efce49f3f95d7d48763a8dfc83ef211 /blame.c
parent939af16eac1608766273d3971598dbcc4fe09928 (diff)
downloadgit-87571c3f71ba41d89eef5202f8589daa26f984ca.zip
git-87571c3f71ba41d89eef5202f8589daa26f984ca.tar.gz
git-87571c3f71ba41d89eef5202f8589daa26f984ca.tar.bz2
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 'blame.c')
-rw-r--r--blame.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/blame.c b/blame.c
index aa46c7e..3d8accf 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) {