Skip to content

Commit a80469b

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 edf9c82 commit a80469b

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
@@ -2212,14 +2212,15 @@ where L::Target: Logger {
22122212
// Can't overflow due to how the values were computed right above.
22132213
None => unreachable!(),
22142214
};
2215+
let htlc_minimum_msat = $candidate.htlc_minimum_msat();
22152216
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
2216-
let over_path_minimum_msat = amount_to_transfer_over_msat >= $candidate.htlc_minimum_msat() &&
2217+
let over_path_minimum_msat = amount_to_transfer_over_msat >= htlc_minimum_msat &&
22172218
amount_to_transfer_over_msat >= $next_hops_path_htlc_minimum_msat;
22182219

22192220
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
22202221
let may_overpay_to_meet_path_minimum_msat =
2221-
((amount_to_transfer_over_msat < $candidate.htlc_minimum_msat() &&
2222-
recommended_value_msat >= $candidate.htlc_minimum_msat()) ||
2222+
((amount_to_transfer_over_msat < htlc_minimum_msat &&
2223+
recommended_value_msat >= htlc_minimum_msat) ||
22232224
(amount_to_transfer_over_msat < $next_hops_path_htlc_minimum_msat &&
22242225
recommended_value_msat >= $next_hops_path_htlc_minimum_msat));
22252226

0 commit comments

Comments
 (0)