Avoid redundant clone. (#6989)

Co-authored-by: eskimor <eskimor@no-such-url.com>
This commit is contained in:
eskimor
2023-03-31 16:53:05 +02:00
committed by GitHub
parent d62d0b48e0
commit 9fe528d5c7
@@ -791,7 +791,7 @@ where
/// as well as their indices in ascending order. /// as well as their indices in ascending order.
fn random_sel<X, F: Fn(&X) -> Weight>( fn random_sel<X, F: Fn(&X) -> Weight>(
rng: &mut rand_chacha::ChaChaRng, rng: &mut rand_chacha::ChaChaRng,
selectables: Vec<X>, selectables: &[X],
mut preferred_indices: Vec<usize>, mut preferred_indices: Vec<usize>,
weight_fn: F, weight_fn: F,
weight_limit: Weight, weight_limit: Weight,
@@ -892,7 +892,7 @@ fn apply_weight_limit<T: Config + inclusion::Config>(
let (acc_candidate_weight, indices) = let (acc_candidate_weight, indices) =
random_sel::<BackedCandidate<<T as frame_system::Config>::Hash>, _>( random_sel::<BackedCandidate<<T as frame_system::Config>::Hash>, _>(
rng, rng,
candidates.clone(), &candidates,
preferred_indices, preferred_indices,
|c| backed_candidate_weight::<T>(c), |c| backed_candidate_weight::<T>(c),
max_consumable_by_candidates, max_consumable_by_candidates,
@@ -911,7 +911,7 @@ fn apply_weight_limit<T: Config + inclusion::Config>(
// into the block and skip the candidates entirely // into the block and skip the candidates entirely
let (total_consumed, indices) = random_sel::<UncheckedSignedAvailabilityBitfield, _>( let (total_consumed, indices) = random_sel::<UncheckedSignedAvailabilityBitfield, _>(
rng, rng,
bitfields.clone(), &bitfields,
vec![], vec![],
|_| <<T as Config>::WeightInfo as WeightInfo>::enter_bitfields(), |_| <<T as Config>::WeightInfo as WeightInfo>::enter_bitfields(),
max_consumable_weight, max_consumable_weight,
@@ -1282,7 +1282,7 @@ fn limit_and_sanitize_disputes<
// Select remote disputes at random until the block is full // Select remote disputes at random until the block is full
let (_acc_remote_disputes_weight, mut indices) = random_sel::<u32, _>( let (_acc_remote_disputes_weight, mut indices) = random_sel::<u32, _>(
rng, rng,
d, &d,
vec![], vec![],
|v| <<T as Config>::WeightInfo as WeightInfo>::enter_variable_disputes(*v), |v| <<T as Config>::WeightInfo as WeightInfo>::enter_variable_disputes(*v),
max_consumable_weight.saturating_sub(weight_acc), max_consumable_weight.saturating_sub(weight_acc),