mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-15 07:50:39 +08:00
bin/patch: Replace manual filter-collect
This patch replaces the manual filtering and pushing of iterators to collections by using the more performant iterator API. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
committed by
Erik Kundt
parent
8772445083
commit
d3dcfd8e09
@@ -114,12 +114,13 @@ impl TryFrom<&Context> for State {
|
||||
let filter = PatchItemFilter::from_str(&context.filter.to_string()).unwrap_or_default();
|
||||
|
||||
// Convert into UI items
|
||||
let mut items = vec![];
|
||||
for patch in patches {
|
||||
if let Ok(item) = PatchItem::new(&context.profile, &context.repository, patch.clone()) {
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
let mut items: Vec<_> = patches
|
||||
.into_iter()
|
||||
.flat_map(|patch| {
|
||||
PatchItem::new(&context.profile, &context.repository, patch.clone()).ok()
|
||||
})
|
||||
.collect();
|
||||
|
||||
items.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));
|
||||
|
||||
Ok(Self {
|
||||
|
||||
Reference in New Issue
Block a user