From f5af55472e4c3e5106021da296db4b8939a9fee6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 17 Aug 2025 12:45:24 +0200 Subject: [PATCH] bin/patch: Optimize collecting of patches into Vec Signed-off-by: Matthias Beyer --- bin/commands/patch/list/imui.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/commands/patch/list/imui.rs b/bin/commands/patch/list/imui.rs index a1858349..fb0cec21 100644 --- a/bin/commands/patch/list/imui.rs +++ b/bin/commands/patch/list/imui.rs @@ -113,12 +113,13 @@ impl TryFrom<&Context> for App { }; let filter = PatchItemFilter::from_str(&context.filter.to_string()).unwrap_or_default(); - 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 = 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(App {