mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 12:38:04 +00:00
Cleanup our sort usage (#6754)
This commit is contained in:
@@ -893,7 +893,7 @@ impl<T: Trait<I>, I: Instance> ChangeMembers<T::AccountId> for Module<T, I> {
|
||||
}
|
||||
// remove accounts from all current voting in motions.
|
||||
let mut outgoing = outgoing.to_vec();
|
||||
outgoing.sort_unstable();
|
||||
outgoing.sort();
|
||||
for h in Self::proposals().into_iter() {
|
||||
<Voting<T, I>>::mutate(h, |v|
|
||||
if let Some(mut votes) = v.take() {
|
||||
|
||||
@@ -1211,7 +1211,7 @@ where
|
||||
/// the order of items is not preserved.
|
||||
fn has_duplicates<T: PartialEq + AsRef<[u8]>>(items: &mut Vec<T>) -> bool {
|
||||
// Sort the vector
|
||||
items.sort_unstable_by(|a, b| {
|
||||
items.sort_by(|a, b| {
|
||||
Ord::cmp(a.as_ref(), b.as_ref())
|
||||
});
|
||||
// And then find any two consecutive equal elements.
|
||||
|
||||
@@ -1238,12 +1238,12 @@ decl_storage! {
|
||||
decl_event!(
|
||||
pub enum Event<T> where Balance = BalanceOf<T>, <T as frame_system::Trait>::AccountId {
|
||||
/// The era payout has been set; the first balance is the validator-payout; the second is
|
||||
/// the remainder from the maximum amount of reward.
|
||||
/// the remainder from the maximum amount of reward.
|
||||
/// [era_index, validator_payout, remainder]
|
||||
EraPayout(EraIndex, Balance, Balance),
|
||||
/// The staker has been rewarded by this amount. [stash, amount]
|
||||
Reward(AccountId, Balance),
|
||||
/// One validator (and its nominators) has been slashed by the given amount.
|
||||
/// One validator (and its nominators) has been slashed by the given amount.
|
||||
/// [validator, amount]
|
||||
Slash(AccountId, Balance),
|
||||
/// An old slashing report from a prior era was discarded because it could
|
||||
@@ -2889,7 +2889,7 @@ impl<T: Trait> Module<T> {
|
||||
let mut exposure_clipped = exposure;
|
||||
let clipped_max_len = T::MaxNominatorRewardedPerValidator::get() as usize;
|
||||
if exposure_clipped.others.len() > clipped_max_len {
|
||||
exposure_clipped.others.sort_unstable_by(|a, b| a.value.cmp(&b.value).reverse());
|
||||
exposure_clipped.others.sort_by(|a, b| a.value.cmp(&b.value).reverse());
|
||||
exposure_clipped.others.truncate(clipped_max_len);
|
||||
}
|
||||
<ErasStakersClipped<T>>::insert(¤t_era, &stash, exposure_clipped);
|
||||
|
||||
@@ -1238,7 +1238,7 @@ pub trait ChangeMembers<AccountId: Clone + Ord> {
|
||||
///
|
||||
/// This resets any previous value of prime.
|
||||
fn change_members(incoming: &[AccountId], outgoing: &[AccountId], mut new: Vec<AccountId>) {
|
||||
new.sort_unstable();
|
||||
new.sort();
|
||||
Self::change_members_sorted(incoming, outgoing, &new[..]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user