Skip to content

Commit f7f6dbf

Browse files
committed
DRY redundant calls to $candidate.htlc_minimum_msat() in routing
While LLVM should inline and elide the redundant calls, because the router is rather large LLVM can decide against inlining in some cases where it would be an nice win. Thus, its worth DRY'ing the redundant calls explicitly.
1 parent 46a9f78 commit f7f6dbf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lightning/src/routing/router.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,14 +2359,15 @@ where L::Target: Logger {
23592359
// Can't overflow due to how the values were computed right above.
23602360
None => unreachable!(),
23612361
};
2362+
let htlc_minimum_msat = $candidate.htlc_minimum_msat();
23622363
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
2363-
let over_path_minimum_msat = amount_to_transfer_over_msat >= $candidate.htlc_minimum_msat() &&
2364+
let over_path_minimum_msat = amount_to_transfer_over_msat >= htlc_minimum_msat &&
23642365
amount_to_transfer_over_msat >= $next_hops_path_htlc_minimum_msat;
23652366

23662367
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
23672368
let may_overpay_to_meet_path_minimum_msat =
2368-
((amount_to_transfer_over_msat < $candidate.htlc_minimum_msat() &&
2369-
recommended_value_msat >= $candidate.htlc_minimum_msat()) ||
2369+
((amount_to_transfer_over_msat < htlc_minimum_msat &&
2370+
recommended_value_msat >= htlc_minimum_msat) ||
23702371
(amount_to_transfer_over_msat < $next_hops_path_htlc_minimum_msat &&
23712372
recommended_value_msat >= $next_hops_path_htlc_minimum_msat));
23722373

0 commit comments

Comments
 (0)