on master help sign in
Specify vector capacity on surround_add
2c1313cBlaž Hrastnik
helix-term/src/commands.rs+1−1
@@ -4698,7 +4698,7 @@ fn surround_add(cx: &mut Context) {
4698 let selection = doc.selection(view.id);
4698 let selection = doc.selection(view.id);
4699 let (open, close) = surround::get_pair(ch);
4699 let (open, close) = surround::get_pair(ch);
4700
4700
4701− let mut changes = Vec::new();
4701+ let mut changes = Vec::with_capacity(selection.len() * 2);
4702 for range in selection.iter() {
4702 for range in selection.iter() {
4703 changes.push((range.from(), range.from(), Some(Tendril::from_char(open))));
4703 changes.push((range.from(), range.from(), Some(Tendril::from_char(open))));
4704 changes.push((range.to(), range.to(), Some(Tendril::from_char(close))));
4704 changes.push((range.to(), range.to(), Some(Tendril::from_char(close))));