Skip to content

Commit

Permalink
plugins/pay: iterate the htable properly, not from start each time.
Browse files Browse the repository at this point in the history
time lightning-cli -R --network=regtest --lightning-dir /tmp/ltests-k8jhvtty/test_pay_stress_1/lightning-1/ listpays > /dev/null

Before:
	real	0m12.447s
	user	0m0.143s
	sys	0m0.008s

After:
	real	0m2.054s
	user	0m0.114s
	sys	0m0.024s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Aug 21, 2020
1 parent 05636e3 commit 4ba3797
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,10 +1858,11 @@ static struct command_result *listsendpays_done(struct command *cmd,
}
}

/* Now we've collapsed them, provide summary (free mem as we go). */
while ((pm = pay_map_first(&pay_map, &it)) != NULL) {
/* Now we've collapsed them, provide summary. */
for (pm = pay_map_first(&pay_map, &it);
pm;
pm = pay_map_next(&pay_map, &it)) {
add_new_entry(ret, buf, pm);
pay_map_del(&pay_map, pm);
}
pay_map_clear(&pay_map);

Expand Down

0 comments on commit 4ba3797

Please sign in to comment.