plugins/pay: iterate the htable properly, not from start each time.

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>
This commit is contained in:
Rusty Russell 2020-08-20 23:10:34 +09:30
parent 05636e367e
commit 4ba3797923

View File

@ -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);