Skip to content

Commit 3c69c91

Browse files
committed
s/sort_by_cached_key/sort_unstable_by_key.
1 parent bac1188 commit 3c69c91

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lightning/src/routing/router.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ where L::Target: Logger {
14421442
}
14431443

14441444
// Sort by total fees and take the best paths.
1445-
payment_paths.sort_by_cached_key(|path| path.get_total_fee_paid_msat());
1445+
payment_paths.sort_unstable_by_key(|path| path.get_total_fee_paid_msat());
14461446
if payment_paths.len() > 50 {
14471447
payment_paths.truncate(50);
14481448
}
@@ -1512,7 +1512,7 @@ where L::Target: Logger {
15121512
// Now, subtract the overpaid value from the most-expensive path.
15131513
// TODO: this could also be optimized by also sorting by feerate_per_sat_routed,
15141514
// so that the sender pays less fees overall. And also htlc_minimum_msat.
1515-
cur_route.sort_by_cached_key(|path| { path.hops.iter().map(|hop| hop.0.candidate.fees().proportional_millionths as u64).sum::<u64>() });
1515+
cur_route.sort_unstable_by_key(|path| { path.hops.iter().map(|hop| hop.0.candidate.fees().proportional_millionths as u64).sum::<u64>() });
15161516
let expensive_payment_path = cur_route.first_mut().unwrap();
15171517

15181518
// We already dropped all the small value paths above, meaning all the
@@ -1528,7 +1528,7 @@ where L::Target: Logger {
15281528

15291529
// Step (9).
15301530
// Select the best route by lowest total fee.
1531-
drawn_routes.sort_by_cached_key(|paths| paths.iter().map(|path| path.get_total_fee_paid_msat()).sum::<u64>());
1531+
drawn_routes.sort_unstable_by_key(|paths| paths.iter().map(|path| path.get_total_fee_paid_msat()).sum::<u64>());
15321532
let mut selected_paths = Vec::<Vec<Result<RouteHop, LightningError>>>::new();
15331533
for payment_path in drawn_routes.first().unwrap() {
15341534
let mut path = payment_path.hops.iter().map(|(payment_hop, node_features)| {

0 commit comments

Comments
 (0)