Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Parachains runtime improvements #4419

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,954 changes: 0 additions & 2,954 deletions runtime/parachains/src/inclusion.rs

This file was deleted.

1,043 changes: 1,043 additions & 0 deletions runtime/parachains/src/inclusion/mod.rs

Large diffs are not rendered by default.

1,911 changes: 1,911 additions & 0 deletions runtime/parachains/src/inclusion/tests.rs

Large diffs are not rendered by default.

2,244 changes: 0 additions & 2,244 deletions runtime/parachains/src/paras_inherent.rs

This file was deleted.

40 changes: 40 additions & 0 deletions runtime/parachains/src/paras_inherent/misc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use sp_std::vec::Vec;

/// A helper trait to allow calling retain while getting access
/// to the index of the item in the `vec`.
pub trait IndexedRetain<T> {
/// Retains only the elements specified by the predicate.
///
/// In other words, remove all elements `e` residing at
/// index `i` such that `f(i, &e)` returns `false`. This method
/// operates in place, visiting each element exactly once in the
/// original order, and preserves the order of the retained elements.
fn indexed_retain(&mut self, f: impl FnMut(usize, &T) -> bool);
}

impl<T> IndexedRetain<T> for Vec<T> {
fn indexed_retain(&mut self, mut f: impl FnMut(usize, &T) -> bool) {
let mut idx = 0_usize;
self.retain(move |item| {
let ret = f(idx, item);
idx += 1_usize;
ret
})
}
}
Loading