Replace some hot TreeMaps with Arc<HashMap> (#49984)

These tend to be very often mutated while we don't really need the
subtree sharing of TreeMaps, so replacing them here is generally
cheaper.

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Co-authored by: John Tur <jtur@zed.dev>
This commit is contained in:
Lukas Wirth authored and GitHub committed 2026-02-25 09:10:29 +01:00
1 parent 7e3e168761
commit ca066cbefd
5 files changed
+41 -31

No files matched your search

+5 -2
View File
@@ -624,7 +624,7 @@ pub struct MultiBufferSnapshot {
diffs: TreeMap<BufferId, DiffStateSnapshot>,
diff_transforms: SumTree<DiffTransform>,
excerpt_ids: SumTree<ExcerptIdMapping>,
replaced_excerpts: TreeMap<ExcerptId, ExcerptId>,
replaced_excerpts: Arc<HashMap<ExcerptId, ExcerptId>>,
non_text_state_update_count: usize,
edit_count: usize,
is_dirty: bool,
@@ -1967,7 +1967,10 @@ impl MultiBuffer {
*has_deleted_file = false;
*has_conflict = false;
*has_inverted_diff = false;
replaced_excerpts.clear();
match Arc::get_mut(replaced_excerpts) {
Some(replaced_excerpts) => replaced_excerpts.clear(),
None => *replaced_excerpts = Default::default(),
}
let edits = Self::sync_diff_transforms(
self.snapshot.get_mut(),