Skip to content

Commit 84fa714

Browse files
committed
Omit unnecessary clone.
1 parent fff2e07 commit 84fa714

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lightning/src/routing/router.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1460,23 +1460,22 @@ where L::Target: Logger {
14601460

14611461
// Step (6).
14621462
// Do a Fisher-Yates shuffle to create a unique permutation of the payment paths
1463-
let cur_payment_paths = loop {
1464-
let mut cur_perm = payment_paths.clone();
1465-
for cur_index in (1..cur_perm.len()).rev() {
1463+
loop {
1464+
for cur_index in (1..payment_paths.len()).rev() {
14661465
prng.process_in_place(&mut random_index_bytes);
14671466
let random_index = usize::from_be_bytes(random_index_bytes).wrapping_rem(cur_index+1);
1468-
cur_perm.swap(cur_index, random_index);
1467+
payment_paths.swap(cur_index, random_index);
14691468
}
1470-
let cur_perm_scids = cur_perm.iter().map(|path|
1469+
let cur_perm_scids = payment_paths.iter().map(|path|
14711470
path.hops.iter().map(|(hop,_)| hop.candidate.short_channel_id()).collect::<Vec<u64>>()
14721471
).collect::<Vec<Vec<u64>>>();
14731472
if seen_permutation_scids.insert(cur_perm_scids) {
1474-
break cur_perm;
1473+
break;
14751474
}
14761475
};
14771476

14781477
// Step (7).
1479-
for payment_path in cur_payment_paths {
1478+
for payment_path in &payment_paths {
14801479
cur_route.push(payment_path.clone());
14811480
aggregate_route_value_msat += payment_path.get_value_msat();
14821481
if aggregate_route_value_msat > final_value_msat {

0 commit comments

Comments
 (0)