Skip to content

Commit 9ff6b79

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 76e8e0f commit 9ff6b79

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
@@ -2425,14 +2425,15 @@ where L::Target: Logger {
24252425
// Can't overflow due to how the values were computed right above.
24262426
None => unreachable!(),
24272427
};
2428+
let htlc_minimum_msat = $candidate.htlc_minimum_msat();
24282429
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
2429-
let over_path_minimum_msat = amount_to_transfer_over_msat >= $candidate.htlc_minimum_msat() &&
2430+
let over_path_minimum_msat = amount_to_transfer_over_msat >= htlc_minimum_msat &&
24302431
amount_to_transfer_over_msat >= $next_hops_path_htlc_minimum_msat;
24312432

24322433
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
24332434
let may_overpay_to_meet_path_minimum_msat =
2434-
((amount_to_transfer_over_msat < $candidate.htlc_minimum_msat() &&
2435-
recommended_value_msat >= $candidate.htlc_minimum_msat()) ||
2435+
((amount_to_transfer_over_msat < htlc_minimum_msat &&
2436+
recommended_value_msat >= htlc_minimum_msat) ||
24362437
(amount_to_transfer_over_msat < $next_hops_path_htlc_minimum_msat &&
24372438
recommended_value_msat >= $next_hops_path_htlc_minimum_msat));
24382439

0 commit comments

Comments
 (0)