on master help sign in
minor: cloning filter and using count() is wasteful here
a3173c2Blaž Hrastnik
helix-term/src/commands.rs+13−9
@@ -5002,16 +5002,20 @@ fn increment_impl(cx: &mut Context, increment_direction: IncrementDirection) {
5002 overlapping_indexes.insert(i + 1);
5002 overlapping_indexes.insert(i + 1);
5003 }
5003 }
5004 }
5004 }
5005+ let changes: Vec<_> = changes
5006+ .into_iter()
5007+ .enumerate()
5005− let changes = changes.into_iter().enumerate().filter_map(|(i, change)| {
5008+ .filter_map(|(i, change)| {
5006− if overlapping_indexes.contains(&i) {
5009+ if overlapping_indexes.contains(&i) {
5007− None
5010+ None
5008− } else {
5011+ } else {
5009− Some(change)
5012+ Some(change)
5013+ }
5010− }
5014+ })
5011− });
5015+ .collect();
5012
5016
5013− if changes.clone().count() > 0 {
5017+ if !changes.is_empty() {
5014− let transaction = Transaction::change(doc.text(), changes);
5018+ let transaction = Transaction::change(doc.text(), changes.into_iter());
5015 let transaction = transaction.with_selection(selection.clone());
5019 let transaction = transaction.with_selection(selection.clone());
5016
5020
5017 apply_transaction(&transaction, doc, view);
5021 apply_transaction(&transaction, doc, view);