minor: cloning filter and using count() is wasteful here

pull/4781/head
Blaž Hrastnik 2 years ago
parent f843967059
commit a3173c2280
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -5002,16 +5002,20 @@ fn increment_impl(cx: &mut Context, increment_direction: IncrementDirection) {
overlapping_indexes.insert(i + 1); overlapping_indexes.insert(i + 1);
} }
} }
let changes = changes.into_iter().enumerate().filter_map(|(i, change)| { let changes: Vec<_> = changes
.into_iter()
.enumerate()
.filter_map(|(i, change)| {
if overlapping_indexes.contains(&i) { if overlapping_indexes.contains(&i) {
None None
} else { } else {
Some(change) Some(change)
} }
}); })
.collect();
if changes.clone().count() > 0 { if !changes.is_empty() {
let transaction = Transaction::change(doc.text(), changes); let transaction = Transaction::change(doc.text(), changes.into_iter());
let transaction = transaction.with_selection(selection.clone()); let transaction = transaction.with_selection(selection.clone());
apply_transaction(&transaction, doc, view); apply_transaction(&transaction, doc, view);

Loading…
Cancel
Save