multi_buffer: Pre-allocate IDs when editing (#36819)

Something I came across when looking at `edit_internal`. Potentially
saves multiple re-allocations on an edit

Release Notes:

- N/A
This commit is contained in:
tidely 2025-08-24 09:59:32 +03:00 committed by GitHub
parent de5f87e8f2
commit dd6fce6d4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -835,7 +835,7 @@ impl MultiBuffer {
this.convert_edits_to_buffer_edits(edits, &snapshot, &original_indent_columns);
drop(snapshot);
let mut buffer_ids = Vec::new();
let mut buffer_ids = Vec::with_capacity(buffer_edits.len());
for (buffer_id, mut edits) in buffer_edits {
buffer_ids.push(buffer_id);
edits.sort_by_key(|edit| edit.range.start);