Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
text: Store fragment's deletions on stack (#49726)
Marco Mihai Condrache9b0cb4ec2051
diff --git a/crates/text/src/text.rs b/crates/text/src/text.rsindex 43e41fd4d28..38ebc214872 100644--- a/crates/text/src/text.rs+++ b/crates/text/src/text.rs@@ -23,6 +23,7 @@ use postage::{oneshot, prelude::*};use regex::Regex;pub use rope::*;pub use selection::*;+use smallvec::SmallVec;use std::{borrow::Cow,cmp::{self, Ordering, Reverse},@@ -541,7 +542,7 @@ pub struct Fragment {pub insertion_offset: usize,pub len: usize,pub visible: bool,- pub deletions: HashSet<clock::Lamport>,+ pub deletions: SmallVec<[clock::Lamport; 2]>,pub max_undos: clock::Global,}@@ -948,7 +949,7 @@ impl Buffer {intersection.insertion_offset += fragment_start - old_fragments.start().visible;intersection.id =Locator::between(&new_fragments.summary().max_id, &intersection.id);- intersection.deletions.insert(timestamp);+ intersection.deletions.push(timestamp);intersection.visible = false;}if intersection.len > 0 {@@ -1197,7 +1198,7 @@ impl Buffer {fragment_start - old_fragments.start().0.full_offset();intersection.id =Locator::between(&new_fragments.summary().max_id, &intersection.id);- intersection.deletions.insert(timestamp);+ intersection.deletions.push(timestamp);intersection.visible = false;insertion_slices.push(InsertionSlice::from_fragment(timestamp, &intersection));}