Skip to content

Commit a6475a1

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 d513807 commit a6475a1

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
@@ -2202,14 +2202,15 @@ where L::Target: Logger {
22022202
// Can't overflow due to how the values were computed right above.
22032203
None => unreachable!(),
22042204
};
2205+
let htlc_minimum_msat = $candidate.htlc_minimum_msat();
22052206
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
2206-
let over_path_minimum_msat = amount_to_transfer_over_msat >= $candidate.htlc_minimum_msat() &&
2207+
let over_path_minimum_msat = amount_to_transfer_over_msat >= htlc_minimum_msat &&
22072208
amount_to_transfer_over_msat >= $next_hops_path_htlc_minimum_msat;
22082209

22092210
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
22102211
let may_overpay_to_meet_path_minimum_msat =
2211-
((amount_to_transfer_over_msat < $candidate.htlc_minimum_msat() &&
2212-
recommended_value_msat >= $candidate.htlc_minimum_msat()) ||
2212+
((amount_to_transfer_over_msat < htlc_minimum_msat &&
2213+
recommended_value_msat >= htlc_minimum_msat) ||
22132214
(amount_to_transfer_over_msat < $next_hops_path_htlc_minimum_msat &&
22142215
recommended_value_msat >= $next_hops_path_htlc_minimum_msat));
22152216

0 commit comments

Comments
 (0)