From a3173c2280aecfcb3d79254058f993c43cab5b90 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 16 Nov 2022 17:54:41 +0900 Subject: minor: cloning filter and using count() is wasteful here --- helix-term/src/commands.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index f5bf6bf1..2d455df0 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -5002,16 +5002,20 @@ fn increment_impl(cx: &mut Context, increment_direction: IncrementDirection) { overlapping_indexes.insert(i + 1); } } - let changes = changes.into_iter().enumerate().filter_map(|(i, change)| { - if overlapping_indexes.contains(&i) { - None - } else { - Some(change) - } - }); + let changes: Vec<_> = changes + .into_iter() + .enumerate() + .filter_map(|(i, change)| { + if overlapping_indexes.contains(&i) { + None + } else { + Some(change) + } + }) + .collect(); - if changes.clone().count() > 0 { - let transaction = Transaction::change(doc.text(), changes); + if !changes.is_empty() { + let transaction = Transaction::change(doc.text(), changes.into_iter()); let transaction = transaction.with_selection(selection.clone()); apply_transaction(&transaction, doc, view); -- cgit v1.2.3-70-g09d2