aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-11-16 08:54:41 +0000
committerBlaž Hrastnik2022-11-16 09:14:30 +0000
commita3173c2280aecfcb3d79254058f993c43cab5b90 (patch)
tree8e58b3ebbfaae66b7db98ddb0251995883ceca9a /helix-term
parentf843967059fc36bf497bde31ce9ed18b1354f1eb (diff)
minor: cloning filter and using count() is wasteful here
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs22
1 files changed, 13 insertions, 9 deletions
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);