Skip to content

Commit

Permalink
minor: cloning filter and using count() is wasteful here
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Nov 16, 2022
1 parent f843967 commit a3173c2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a3173c2

Please sign in to comment.