wrap_map: Add capacity to vectors for better performance (#31055)

Release Notes:

- N/A
This commit is contained in:
Remco Smits 2025-05-21 01:44:19 +02:00 committed by GitHub
parent a824119367
commit 44fbe27d31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -411,7 +411,7 @@ impl WrapSnapshot {
}
let mut tab_edits_iter = tab_edits.iter().peekable();
let mut row_edits = Vec::new();
let mut row_edits = Vec::with_capacity(tab_edits.len());
while let Some(edit) = tab_edits_iter.next() {
let mut row_edit = RowEdit {
old_rows: edit.old.start.row()..edit.old.end.row() + 1,
@ -561,7 +561,7 @@ impl WrapSnapshot {
}
fn compute_edits(&self, tab_edits: &[TabEdit], new_snapshot: &WrapSnapshot) -> Patch<u32> {
let mut wrap_edits = Vec::new();
let mut wrap_edits = Vec::with_capacity(tab_edits.len());
let mut old_cursor = self.transforms.cursor::<TransformSummary>(&());
let mut new_cursor = new_snapshot.transforms.cursor::<TransformSummary>(&());
for mut tab_edit in tab_edits.iter().cloned() {