sum_tree: Reduce Cursor size for contextless summary types (#38776)
This reduces the size of cursor by a usize when the summary does not
require a context making Cursor usages and constructions slightly more
efficient.
This change is a bit annoying though, as Rust has no means of
specializing, so this uses a `ContextlessSummary` trait with a blanket
impl while turning the `Context` into a GAT `Context<'a>`. This means
`Summary` implies are a bit more verbose now while contextless ones are
slimmer. It does come with the downside that the lifetime in the GAT is
always considered invariant, so some lifetime splitting occurred due to
that.
```
push/4096 time: [352.65 µs 360.87 µs 367.80 µs]
thrpt: [10.621 MiB/s 10.825 MiB/s 11.077 MiB/s]
change:
time: [-2.6633% -1.3640% -0.0561%] (p = 0.05 < 0.05)
thrpt: [+0.0561% +1.3828% +2.7361%]
Change within noise threshold.
Found 16 outliers among 100 measurements (16.00%)
7 (7.00%) low severe
3 (3.00%) low mild
2 (2.00%) high mild
4 (4.00%) high severe
push/65536 time: [1.2917 ms 1.2949 ms 1.2979 ms]
thrpt: [48.156 MiB/s 48.267 MiB/s 48.387 MiB/s]
change:
time: [+1.4428% +1.9844% +2.5299%] (p = 0.00 < 0.05)
thrpt: [-2.4675% -1.9458% -1.4223%]
Performance has regressed.
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) low severe
1 (1.00%) low mild
1 (1.00%) high severe
append/4096 time: [677.87 ns 678.87 ns 679.83 ns]
thrpt: [5.6112 GiB/s 5.6192 GiB/s 5.6274 GiB/s]
change:
time: [-0.8924% -0.5017% -0.1705%] (p = 0.00 < 0.05)
thrpt: [+0.1708% +0.5043% +0.9004%]
Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high mild
append/65536 time: [9.3275 µs 9.3406 µs 9.3536 µs]
thrpt: [6.5253 GiB/s 6.5344 GiB/s 6.5435 GiB/s]
change:
time: [+0.5409% +0.7215% +0.9054%] (p = 0.00 < 0.05)
thrpt: [-0.8973% -0.7163% -0.5380%]
Change within noise threshold.
slice/4096 time: [27.673 µs 27.791 µs 27.907 µs]
thrpt: [139.97 MiB/s 140.56 MiB/s 141.16 MiB/s]
change:
time: [-1.1065% -0.6725% -0.2429%] (p = 0.00 < 0.05)
thrpt: [+0.2435% +0.6770% +1.1189%]
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) low mild
1 (1.00%) high mild
slice/65536 time: [507.55 µs 517.40 µs 535.60 µs]
thrpt: [116.69 MiB/s 120.80 MiB/s 123.14 MiB/s]
change:
time: [-1.3489% +0.0599% +2.2591%] (p = 0.96 > 0.05)
thrpt: [-2.2092% -0.0598% +1.3674%]
No change in performance detected.
Found 8 outliers among 100 measurements (8.00%)
5 (5.00%) low mild
2 (2.00%) high mild
1 (1.00%) high severe
bytes_in_range/4096 time: [3.3917 µs 3.4108 µs 3.4313 µs]
thrpt: [1.1117 GiB/s 1.1184 GiB/s 1.1247 GiB/s]
change:
time: [-5.3466% -4.7193% -4.1262%] (p = 0.00 < 0.05)
thrpt: [+4.3038% +4.9531% +5.6487%]
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
1 (1.00%) low mild
5 (5.00%) high mild
bytes_in_range/65536 time: [88.175 µs 88.613 µs 89.111 µs]
thrpt: [701.37 MiB/s 705.31 MiB/s 708.82 MiB/s]
change:
time: [-0.6935% +0.3769% +1.4655%] (p = 0.50 > 0.05)
thrpt: [-1.4443% -0.3755% +0.6984%]
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
chars/4096 time: [678.70 ns 680.38 ns 682.08 ns]
thrpt: [5.5927 GiB/s 5.6067 GiB/s 5.6206 GiB/s]
change:
time: [-0.6969% -0.2755% +0.1485%] (p = 0.20 > 0.05)
thrpt: [-0.1483% +0.2763% +0.7018%]
No change in performance detected.
Found 9 outliers among 100 measurements (9.00%)
5 (5.00%) low mild
4 (4.00%) high mild
chars/65536 time: [12.720 µs 12.775 µs 12.830 µs]
thrpt: [4.7573 GiB/s 4.7778 GiB/s 4.7983 GiB/s]
change:
time: [-0.6172% -0.1110% +0.4179%] (p = 0.68 > 0.05)
thrpt: [-0.4162% +0.1112% +0.6211%]
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high mild
clip_point/4096 time: [33.240 µs 33.310 µs 33.394 µs]
thrpt: [116.98 MiB/s 117.27 MiB/s 117.52 MiB/s]
change:
time: [-2.8892% -2.6305% -2.3438%] (p = 0.00 < 0.05)
thrpt: [+2.4000% +2.7015% +2.9751%]
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
1 (1.00%) low mild
4 (4.00%) high mild
7 (7.00%) high severe
clip_point/65536 time: [1.6531 ms 1.6586 ms 1.6640 ms]
thrpt: [37.560 MiB/s 37.683 MiB/s 37.808 MiB/s]
change:
time: [-6.6381% -5.9395% -5.2680%] (p = 0.00 < 0.05)
thrpt: [+5.5610% +6.3146% +7.1100%]
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
1 (1.00%) low mild
2 (2.00%) high mild
4 (4.00%) high severe
point_to_offset/4096 time: [11.586 µs 11.603 µs 11.621 µs]
thrpt: [336.15 MiB/s 336.67 MiB/s 337.16 MiB/s]
change:
time: [-14.289% -14.111% -13.939%] (p = 0.00 < 0.05)
thrpt: [+16.197% +16.429% +16.672%]
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
3 (3.00%) low severe
5 (5.00%) low mild
4 (4.00%) high mild
point_to_offset/65536 time: [527.74 µs 532.08 µs 536.51 µs]
thrpt: [116.49 MiB/s 117.46 MiB/s 118.43 MiB/s]
change:
time: [-6.7825% -4.6235% -2.3533%] (p = 0.00 < 0.05)
thrpt: [+2.4100% +4.8477% +7.2760%]
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
4 (4.00%) high mild
4 (4.00%) high severe
cursor/4096 time: [16.154 µs 16.192 µs 16.232 µs]
thrpt: [240.66 MiB/s 241.24 MiB/s 241.81 MiB/s]
change:
time: [-3.2536% -2.9145% -2.5526%] (p = 0.00 < 0.05)
thrpt: [+2.6194% +3.0019% +3.3630%]
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
1 (1.00%) low mild
2 (2.00%) high mild
2 (2.00%) high severe
cursor/65536 time: [509.60 µs 511.24 µs 512.93 µs]
thrpt: [121.85 MiB/s 122.25 MiB/s 122.65 MiB/s]
change:
time: [-7.3677% -6.6017% -5.7840%] (p = 0.00 < 0.05)
thrpt: [+6.1391% +7.0683% +7.9537%]
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
3 (3.00%) high mild
3 (3.00%) high severe
```
Release Notes:
- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -412,7 +412,7 @@ struct Excerpt {
|
||||
#[derive(Clone)]
|
||||
pub struct MultiBufferExcerpt<'a> {
|
||||
excerpt: &'a Excerpt,
|
||||
diff_transforms: sum_tree::Cursor<'a, DiffTransform, DiffTransforms<usize>>,
|
||||
diff_transforms: sum_tree::Cursor<'a, 'static, DiffTransform, DiffTransforms<usize>>,
|
||||
offset: usize,
|
||||
excerpt_offset: ExcerptDimension<usize>,
|
||||
buffer_offset: usize,
|
||||
@@ -468,8 +468,8 @@ pub struct MultiBufferRows<'a> {
|
||||
}
|
||||
|
||||
pub struct MultiBufferChunks<'a> {
|
||||
excerpts: Cursor<'a, Excerpt, ExcerptOffset>,
|
||||
diff_transforms: Cursor<'a, DiffTransform, Dimensions<usize, ExcerptOffset>>,
|
||||
excerpts: Cursor<'a, 'static, Excerpt, ExcerptOffset>,
|
||||
diff_transforms: Cursor<'a, 'static, DiffTransform, Dimensions<usize, ExcerptOffset>>,
|
||||
diffs: &'a TreeMap<BufferId, BufferDiffSnapshot>,
|
||||
diff_base_chunks: Option<(BufferId, BufferChunks<'a>)>,
|
||||
buffer_chunk: Option<Chunk<'a>>,
|
||||
@@ -507,7 +507,7 @@ struct DiffTransforms<D> {
|
||||
}
|
||||
|
||||
impl<'a, D: TextDimension> Dimension<'a, DiffTransformSummary> for DiffTransforms<D> {
|
||||
fn zero(cx: &<DiffTransformSummary as sum_tree::Summary>::Context) -> Self {
|
||||
fn zero(cx: <DiffTransformSummary as sum_tree::Summary>::Context<'_>) -> Self {
|
||||
Self {
|
||||
output_dimension: OutputDimension::zero(cx),
|
||||
excerpt_dimension: <ExcerptDimension<D> as Dimension<'a, DiffTransformSummary>>::zero(
|
||||
@@ -519,7 +519,7 @@ impl<'a, D: TextDimension> Dimension<'a, DiffTransformSummary> for DiffTransform
|
||||
fn add_summary(
|
||||
&mut self,
|
||||
summary: &'a DiffTransformSummary,
|
||||
cx: &<DiffTransformSummary as sum_tree::Summary>::Context,
|
||||
cx: <DiffTransformSummary as sum_tree::Summary>::Context<'_>,
|
||||
) {
|
||||
self.output_dimension.add_summary(summary, cx);
|
||||
self.excerpt_dimension.add_summary(summary, cx);
|
||||
@@ -528,8 +528,8 @@ impl<'a, D: TextDimension> Dimension<'a, DiffTransformSummary> for DiffTransform
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MultiBufferCursor<'a, D: TextDimension> {
|
||||
excerpts: Cursor<'a, Excerpt, ExcerptDimension<D>>,
|
||||
diff_transforms: Cursor<'a, DiffTransform, DiffTransforms<D>>,
|
||||
excerpts: Cursor<'a, 'static, Excerpt, ExcerptDimension<D>>,
|
||||
diff_transforms: Cursor<'a, 'static, DiffTransform, DiffTransforms<D>>,
|
||||
diffs: &'a TreeMap<BufferId, BufferDiffSnapshot>,
|
||||
cached_region: Option<MultiBufferRegion<'a, D>>,
|
||||
}
|
||||
@@ -1196,7 +1196,7 @@ impl MultiBuffer {
|
||||
let mut ranges = Vec::new();
|
||||
let snapshot = self.read(cx);
|
||||
let buffers = self.buffers.borrow();
|
||||
let mut cursor = snapshot.excerpts.cursor::<ExcerptSummary>(&());
|
||||
let mut cursor = snapshot.excerpts.cursor::<ExcerptSummary>(());
|
||||
|
||||
for (buffer_id, buffer_transaction) in &transaction.buffer_transactions {
|
||||
let Some(buffer_state) = buffers.get(buffer_id) else {
|
||||
@@ -1311,7 +1311,7 @@ impl MultiBuffer {
|
||||
let mut selections_by_buffer: HashMap<BufferId, Vec<Selection<text::Anchor>>> =
|
||||
Default::default();
|
||||
let snapshot = self.read(cx);
|
||||
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(());
|
||||
for selection in selections {
|
||||
let start_locator = snapshot.excerpt_locator_for_id(selection.start.excerpt_id);
|
||||
let end_locator = snapshot.excerpt_locator_for_id(selection.end.excerpt_id);
|
||||
@@ -1762,7 +1762,7 @@ impl MultiBuffer {
|
||||
|
||||
let mut next_excerpt_id = move || ExcerptId(post_inc(&mut next_excerpt_id));
|
||||
|
||||
let mut excerpts_cursor = snapshot.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut excerpts_cursor = snapshot.excerpts.cursor::<Option<&Locator>>(());
|
||||
excerpts_cursor.next();
|
||||
|
||||
loop {
|
||||
@@ -1963,7 +1963,7 @@ impl MultiBuffer {
|
||||
|
||||
let mut prev_locator = snapshot.excerpt_locator_for_id(prev_excerpt_id).clone();
|
||||
let mut new_excerpt_ids = mem::take(&mut snapshot.excerpt_ids);
|
||||
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(());
|
||||
let mut new_excerpts = cursor.slice(&prev_locator, Bias::Right);
|
||||
prev_locator = cursor.start().unwrap_or(Locator::min_ref()).clone();
|
||||
|
||||
@@ -1972,7 +1972,7 @@ impl MultiBuffer {
|
||||
|excerpt| {
|
||||
excerpt.has_trailing_newline = true;
|
||||
},
|
||||
&(),
|
||||
(),
|
||||
);
|
||||
|
||||
let next_locator = if let Some(excerpt) = cursor.item() {
|
||||
@@ -2002,20 +2002,20 @@ impl MultiBuffer {
|
||||
range,
|
||||
ranges.peek().is_some() || cursor.item().is_some(),
|
||||
);
|
||||
new_excerpts.push(excerpt, &());
|
||||
new_excerpts.push(excerpt, ());
|
||||
prev_locator = locator.clone();
|
||||
|
||||
if let Some(last_mapping_entry) = new_excerpt_ids.last() {
|
||||
assert!(id > last_mapping_entry.id, "excerpt ids must be increasing");
|
||||
}
|
||||
new_excerpt_ids.push(ExcerptIdMapping { id, locator }, &());
|
||||
new_excerpt_ids.push(ExcerptIdMapping { id, locator }, ());
|
||||
}
|
||||
|
||||
let edit_end = ExcerptOffset::new(new_excerpts.summary().text.len);
|
||||
|
||||
let suffix = cursor.suffix();
|
||||
let changed_trailing_excerpt = suffix.is_empty();
|
||||
new_excerpts.append(suffix, &());
|
||||
new_excerpts.append(suffix, ());
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
snapshot.excerpt_ids = new_excerpt_ids;
|
||||
@@ -2091,7 +2091,7 @@ impl MultiBuffer {
|
||||
let mut excerpts = Vec::new();
|
||||
let snapshot = self.read(cx);
|
||||
let buffers = self.buffers.borrow();
|
||||
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(());
|
||||
if let Some(locators) = buffers.get(&buffer_id).map(|state| &state.excerpts) {
|
||||
for locator in locators {
|
||||
cursor.seek_forward(&Some(locator), Bias::Left);
|
||||
@@ -2111,10 +2111,10 @@ impl MultiBuffer {
|
||||
let buffers = self.buffers.borrow();
|
||||
let mut excerpts = snapshot
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptDimension<Point>>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptDimension<Point>>>(());
|
||||
let mut diff_transforms = snapshot
|
||||
.diff_transforms
|
||||
.cursor::<Dimensions<ExcerptDimension<Point>, OutputDimension<Point>>>(&());
|
||||
.cursor::<Dimensions<ExcerptDimension<Point>, OutputDimension<Point>>>(());
|
||||
diff_transforms.next();
|
||||
let locators = buffers
|
||||
.get(&buffer_id)
|
||||
@@ -2280,7 +2280,7 @@ impl MultiBuffer {
|
||||
let mut new_excerpts = SumTree::default();
|
||||
let mut cursor = snapshot
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(());
|
||||
let mut edits = Vec::new();
|
||||
let mut excerpt_ids = ids.iter().copied().peekable();
|
||||
let mut removed_buffer_ids = Vec::new();
|
||||
@@ -2289,7 +2289,7 @@ impl MultiBuffer {
|
||||
self.paths_by_excerpt.remove(&excerpt_id);
|
||||
// Seek to the next excerpt to remove, preserving any preceding excerpts.
|
||||
let locator = snapshot.excerpt_locator_for_id(excerpt_id);
|
||||
new_excerpts.append(cursor.slice(&Some(locator), Bias::Left), &());
|
||||
new_excerpts.append(cursor.slice(&Some(locator), Bias::Left), ());
|
||||
|
||||
if let Some(mut excerpt) = cursor.item() {
|
||||
if excerpt.id != excerpt_id {
|
||||
@@ -2331,7 +2331,7 @@ impl MultiBuffer {
|
||||
// the previous excerpt.
|
||||
if cursor.item().is_none() && old_start.value > 0 {
|
||||
old_start.value -= 1;
|
||||
new_excerpts.update_last(|e| e.has_trailing_newline = false, &());
|
||||
new_excerpts.update_last(|e| e.has_trailing_newline = false, ());
|
||||
}
|
||||
|
||||
// Push an edit for the removal of this run of excerpts.
|
||||
@@ -2345,7 +2345,7 @@ impl MultiBuffer {
|
||||
}
|
||||
let suffix = cursor.suffix();
|
||||
let changed_trailing_excerpt = suffix.is_empty();
|
||||
new_excerpts.append(suffix, &());
|
||||
new_excerpts.append(suffix, ());
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
for buffer_id in &removed_buffer_ids {
|
||||
@@ -2487,7 +2487,7 @@ impl MultiBuffer {
|
||||
for locator in &buffer_state.excerpts {
|
||||
let mut cursor = snapshot
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(());
|
||||
cursor.seek_forward(&Some(locator), Bias::Left);
|
||||
if let Some(excerpt) = cursor.item()
|
||||
&& excerpt.locator == *locator
|
||||
@@ -2721,7 +2721,7 @@ impl MultiBuffer {
|
||||
|
||||
pub fn single_hunk_is_expanded(&self, range: Range<Anchor>, cx: &App) -> bool {
|
||||
let snapshot = self.read(cx);
|
||||
let mut cursor = snapshot.diff_transforms.cursor::<usize>(&());
|
||||
let mut cursor = snapshot.diff_transforms.cursor::<usize>(());
|
||||
let offset_range = range.to_offset(&snapshot);
|
||||
cursor.seek(&offset_range.start, Bias::Left);
|
||||
while let Some(item) = cursor.item() {
|
||||
@@ -2738,7 +2738,7 @@ impl MultiBuffer {
|
||||
|
||||
pub fn has_expanded_diff_hunks_in_ranges(&self, ranges: &[Range<Anchor>], cx: &App) -> bool {
|
||||
let snapshot = self.read(cx);
|
||||
let mut cursor = snapshot.diff_transforms.cursor::<usize>(&());
|
||||
let mut cursor = snapshot.diff_transforms.cursor::<usize>(());
|
||||
for range in ranges {
|
||||
let range = range.to_point(&snapshot);
|
||||
let start = snapshot.point_to_offset(Point::new(range.start.row, 0));
|
||||
@@ -2844,11 +2844,11 @@ impl MultiBuffer {
|
||||
let mut new_excerpts = SumTree::default();
|
||||
let mut cursor = snapshot
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(());
|
||||
let mut edits = Vec::<Edit<ExcerptOffset>>::new();
|
||||
|
||||
let prefix = cursor.slice(&Some(locator), Bias::Left);
|
||||
new_excerpts.append(prefix, &());
|
||||
new_excerpts.append(prefix, ());
|
||||
|
||||
let mut excerpt = cursor.item().unwrap().clone();
|
||||
let old_text_len = ExcerptOffset::new(excerpt.text_summary.len);
|
||||
@@ -2880,11 +2880,11 @@ impl MultiBuffer {
|
||||
edits.push(edit);
|
||||
}
|
||||
|
||||
new_excerpts.push(excerpt, &());
|
||||
new_excerpts.push(excerpt, ());
|
||||
|
||||
cursor.next();
|
||||
|
||||
new_excerpts.append(cursor.suffix(), &());
|
||||
new_excerpts.append(cursor.suffix(), ());
|
||||
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
@@ -2920,12 +2920,12 @@ impl MultiBuffer {
|
||||
let mut new_excerpts = SumTree::default();
|
||||
let mut cursor = snapshot
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(());
|
||||
let mut edits = Vec::<Edit<ExcerptOffset>>::new();
|
||||
|
||||
for locator in &locators {
|
||||
let prefix = cursor.slice(&Some(locator), Bias::Left);
|
||||
new_excerpts.append(prefix, &());
|
||||
new_excerpts.append(prefix, ());
|
||||
|
||||
let mut excerpt = cursor.item().unwrap().clone();
|
||||
let old_text_len = ExcerptOffset::new(excerpt.text_summary.len);
|
||||
@@ -2984,12 +2984,12 @@ impl MultiBuffer {
|
||||
edits.push(edit);
|
||||
}
|
||||
|
||||
new_excerpts.push(excerpt, &());
|
||||
new_excerpts.push(excerpt, ());
|
||||
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
new_excerpts.append(cursor.suffix(), &());
|
||||
new_excerpts.append(cursor.suffix(), ());
|
||||
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
@@ -3066,10 +3066,10 @@ impl MultiBuffer {
|
||||
let mut new_excerpts = SumTree::default();
|
||||
let mut cursor = snapshot
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(());
|
||||
|
||||
for (locator, buffer, buffer_edited) in excerpts_to_edit {
|
||||
new_excerpts.append(cursor.slice(&Some(locator), Bias::Left), &());
|
||||
new_excerpts.append(cursor.slice(&Some(locator), Bias::Left), ());
|
||||
let old_excerpt = cursor.item().unwrap();
|
||||
let buffer = buffer.read(cx);
|
||||
let buffer_id = buffer.remote_id();
|
||||
@@ -3110,10 +3110,10 @@ impl MultiBuffer {
|
||||
new_excerpt.buffer = buffer.snapshot();
|
||||
}
|
||||
|
||||
new_excerpts.push(new_excerpt, &());
|
||||
new_excerpts.push(new_excerpt, ());
|
||||
cursor.next();
|
||||
}
|
||||
new_excerpts.append(cursor.suffix(), &());
|
||||
new_excerpts.append(cursor.suffix(), ());
|
||||
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
@@ -3131,10 +3131,10 @@ impl MultiBuffer {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut excerpts = snapshot.excerpts.cursor::<ExcerptOffset>(&());
|
||||
let mut excerpts = snapshot.excerpts.cursor::<ExcerptOffset>(());
|
||||
let mut old_diff_transforms = snapshot
|
||||
.diff_transforms
|
||||
.cursor::<Dimensions<ExcerptOffset, usize>>(&());
|
||||
.cursor::<Dimensions<ExcerptOffset, usize>>(());
|
||||
let mut new_diff_transforms = SumTree::default();
|
||||
let mut old_expanded_hunks = HashSet::default();
|
||||
let mut output_edits = Vec::new();
|
||||
@@ -3241,7 +3241,7 @@ impl MultiBuffer {
|
||||
summary: Default::default(),
|
||||
inserted_hunk_info: None,
|
||||
},
|
||||
&(),
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3399,7 +3399,7 @@ impl MultiBuffer {
|
||||
hunk_info,
|
||||
has_trailing_newline,
|
||||
},
|
||||
&(),
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3436,13 +3436,13 @@ impl MultiBuffer {
|
||||
*summary,
|
||||
)
|
||||
{
|
||||
let mut cursor = subtree.cursor::<()>(&());
|
||||
let mut cursor = subtree.cursor::<()>(());
|
||||
cursor.next();
|
||||
cursor.next();
|
||||
new_transforms.append(cursor.suffix(), &());
|
||||
new_transforms.append(cursor.suffix(), ());
|
||||
return;
|
||||
}
|
||||
new_transforms.append(subtree, &());
|
||||
new_transforms.append(subtree, ());
|
||||
}
|
||||
|
||||
fn push_diff_transform(
|
||||
@@ -3462,7 +3462,7 @@ impl MultiBuffer {
|
||||
{
|
||||
return;
|
||||
}
|
||||
new_transforms.push(transform, &());
|
||||
new_transforms.push(transform, ());
|
||||
}
|
||||
|
||||
fn push_buffer_content_transform(
|
||||
@@ -3496,7 +3496,7 @@ impl MultiBuffer {
|
||||
summary: summary_to_add,
|
||||
inserted_hunk_info,
|
||||
},
|
||||
&(),
|
||||
(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -3521,7 +3521,7 @@ impl MultiBuffer {
|
||||
did_extend = true;
|
||||
}
|
||||
},
|
||||
&(),
|
||||
(),
|
||||
);
|
||||
did_extend
|
||||
}
|
||||
@@ -4033,7 +4033,7 @@ impl MultiBufferSnapshot {
|
||||
cursor.seek(&query_range.start);
|
||||
|
||||
if let Some(region) = cursor.region().filter(|region| !region.is_main_buffer)
|
||||
&& region.range.start > D::zero(&())
|
||||
&& region.range.start > D::zero(())
|
||||
{
|
||||
cursor.prev()
|
||||
}
|
||||
@@ -4368,8 +4368,8 @@ impl MultiBufferSnapshot {
|
||||
let mut chunks = MultiBufferChunks {
|
||||
excerpt_offset_range: ExcerptOffset::new(0)..ExcerptOffset::new(0),
|
||||
range: 0..0,
|
||||
excerpts: self.excerpts.cursor(&()),
|
||||
diff_transforms: self.diff_transforms.cursor(&()),
|
||||
excerpts: self.excerpts.cursor(()),
|
||||
diff_transforms: self.diff_transforms.cursor(()),
|
||||
diffs: &self.diffs,
|
||||
diff_base_chunks: None,
|
||||
excerpt_chunks: None,
|
||||
@@ -4706,7 +4706,7 @@ impl MultiBufferSnapshot {
|
||||
let range = range.start.to_offset(self)..range.end.to_offset(self);
|
||||
let mut cursor = self
|
||||
.diff_transforms
|
||||
.cursor::<Dimensions<usize, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<usize, ExcerptOffset>>(());
|
||||
cursor.seek(&range.start, Bias::Right);
|
||||
|
||||
let Some(first_transform) = cursor.item() else {
|
||||
@@ -4801,8 +4801,8 @@ impl MultiBufferSnapshot {
|
||||
D: TextDimension,
|
||||
{
|
||||
// let mut range = range.start..range.end;
|
||||
let mut summary = D::zero(&());
|
||||
let mut cursor = self.excerpts.cursor::<ExcerptOffset>(&());
|
||||
let mut summary = D::zero(());
|
||||
let mut cursor = self.excerpts.cursor::<ExcerptOffset>(());
|
||||
cursor.seek(&range.start, Bias::Right);
|
||||
if let Some(excerpt) = cursor.item() {
|
||||
let mut end_before_newline = cursor.end();
|
||||
@@ -4920,7 +4920,7 @@ impl MultiBufferSnapshot {
|
||||
fn excerpt_offset_for_anchor(&self, anchor: &Anchor) -> ExcerptOffset {
|
||||
let mut cursor = self
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(());
|
||||
let locator = self.excerpt_locator_for_id(anchor.excerpt_id);
|
||||
|
||||
cursor.seek(&Some(locator), Bias::Left);
|
||||
@@ -4960,10 +4960,10 @@ impl MultiBufferSnapshot {
|
||||
I: 'a + IntoIterator<Item = &'a Anchor>,
|
||||
{
|
||||
let mut anchors = anchors.into_iter().peekable();
|
||||
let mut cursor = self.excerpts.cursor::<ExcerptSummary>(&());
|
||||
let mut cursor = self.excerpts.cursor::<ExcerptSummary>(());
|
||||
let mut diff_transforms_cursor = self
|
||||
.diff_transforms
|
||||
.cursor::<Dimensions<ExcerptDimension<D>, OutputDimension<D>>>(&());
|
||||
.cursor::<Dimensions<ExcerptDimension<D>, OutputDimension<D>>>(());
|
||||
diff_transforms_cursor.next();
|
||||
|
||||
let mut summaries = Vec::new();
|
||||
@@ -5081,7 +5081,7 @@ impl MultiBufferSnapshot {
|
||||
I: 'a + IntoIterator<Item = &'a Anchor>,
|
||||
{
|
||||
let mut anchors = anchors.into_iter().enumerate().peekable();
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(());
|
||||
cursor.next();
|
||||
|
||||
let mut result = Vec::new();
|
||||
@@ -5195,7 +5195,7 @@ impl MultiBufferSnapshot {
|
||||
// offset in the excerpts, and whether the position is within a deleted hunk.
|
||||
let mut diff_transforms = self
|
||||
.diff_transforms
|
||||
.cursor::<Dimensions<usize, ExcerptOffset>>(&());
|
||||
.cursor::<Dimensions<usize, ExcerptOffset>>(());
|
||||
diff_transforms.seek(&offset, Bias::Right);
|
||||
|
||||
if offset == diff_transforms.start().0
|
||||
@@ -5232,7 +5232,7 @@ impl MultiBufferSnapshot {
|
||||
|
||||
let mut excerpts = self
|
||||
.excerpts
|
||||
.cursor::<Dimensions<ExcerptOffset, Option<ExcerptId>>>(&());
|
||||
.cursor::<Dimensions<ExcerptOffset, Option<ExcerptId>>>(());
|
||||
excerpts.seek(&excerpt_offset, Bias::Right);
|
||||
if excerpts.item().is_none() && excerpt_offset == excerpts.start().0 && bias == Bias::Left {
|
||||
excerpts.prev();
|
||||
@@ -5277,7 +5277,7 @@ impl MultiBufferSnapshot {
|
||||
) -> Option<Anchor> {
|
||||
let excerpt_id = self.latest_excerpt_id(excerpt_id);
|
||||
let locator = self.excerpt_locator_for_id(excerpt_id);
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(());
|
||||
cursor.seek(locator, Bias::Left);
|
||||
if let Some(excerpt) = cursor.item()
|
||||
&& excerpt.id == excerpt_id
|
||||
@@ -5317,8 +5317,8 @@ impl MultiBufferSnapshot {
|
||||
}
|
||||
|
||||
fn cursor<D: TextDimension + Default>(&self) -> MultiBufferCursor<'_, D> {
|
||||
let excerpts = self.excerpts.cursor(&());
|
||||
let diff_transforms = self.diff_transforms.cursor(&());
|
||||
let excerpts = self.excerpts.cursor(());
|
||||
let diff_transforms = self.diff_transforms.cursor(());
|
||||
MultiBufferCursor {
|
||||
excerpts,
|
||||
diff_transforms,
|
||||
@@ -5331,11 +5331,11 @@ impl MultiBufferSnapshot {
|
||||
let start_locator = self.excerpt_locator_for_id(id);
|
||||
let mut excerpts = self
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptDimension<usize>>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptDimension<usize>>>(());
|
||||
excerpts.seek(&Some(start_locator), Bias::Left);
|
||||
excerpts.prev();
|
||||
|
||||
let mut diff_transforms = self.diff_transforms.cursor::<DiffTransforms<usize>>(&());
|
||||
let mut diff_transforms = self.diff_transforms.cursor::<DiffTransforms<usize>>(());
|
||||
diff_transforms.seek(&excerpts.start().1, Bias::Left);
|
||||
if diff_transforms.end().excerpt_dimension < excerpts.start().1 {
|
||||
diff_transforms.next();
|
||||
@@ -6188,7 +6188,7 @@ impl MultiBufferSnapshot {
|
||||
} else if id == ExcerptId::max() {
|
||||
Locator::max_ref()
|
||||
} else {
|
||||
let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(&());
|
||||
let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(());
|
||||
cursor.seek(&id, Bias::Left);
|
||||
if let Some(entry) = cursor.item()
|
||||
&& entry.id == id
|
||||
@@ -6223,7 +6223,7 @@ impl MultiBufferSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(&());
|
||||
let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(());
|
||||
for id in sorted_ids {
|
||||
if cursor.seek_forward(&id, Bias::Left) {
|
||||
locators.push(cursor.item().unwrap().locator.clone());
|
||||
@@ -6247,14 +6247,14 @@ impl MultiBufferSnapshot {
|
||||
pub fn range_for_excerpt(&self, excerpt_id: ExcerptId) -> Option<Range<Point>> {
|
||||
let mut cursor = self
|
||||
.excerpts
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptDimension<Point>>>(&());
|
||||
.cursor::<Dimensions<Option<&Locator>, ExcerptDimension<Point>>>(());
|
||||
let locator = self.excerpt_locator_for_id(excerpt_id);
|
||||
if cursor.seek(&Some(locator), Bias::Left) {
|
||||
let start = cursor.start().1.clone();
|
||||
let end = cursor.end().1;
|
||||
let mut diff_transforms = self
|
||||
.diff_transforms
|
||||
.cursor::<Dimensions<ExcerptDimension<Point>, OutputDimension<Point>>>(&());
|
||||
.cursor::<Dimensions<ExcerptDimension<Point>, OutputDimension<Point>>>(());
|
||||
diff_transforms.seek(&start, Bias::Left);
|
||||
let overshoot = start.0 - diff_transforms.start().0.0;
|
||||
let start = diff_transforms.start().1.0 + overshoot;
|
||||
@@ -6268,7 +6268,7 @@ impl MultiBufferSnapshot {
|
||||
}
|
||||
|
||||
pub fn buffer_range_for_excerpt(&self, excerpt_id: ExcerptId) -> Option<Range<text::Anchor>> {
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(());
|
||||
let locator = self.excerpt_locator_for_id(excerpt_id);
|
||||
if cursor.seek(&Some(locator), Bias::Left)
|
||||
&& let Some(excerpt) = cursor.item()
|
||||
@@ -6279,7 +6279,7 @@ impl MultiBufferSnapshot {
|
||||
}
|
||||
|
||||
fn excerpt(&self, excerpt_id: ExcerptId) -> Option<&Excerpt> {
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
|
||||
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(());
|
||||
let locator = self.excerpt_locator_for_id(excerpt_id);
|
||||
cursor.seek(&Some(locator), Bias::Left);
|
||||
if let Some(excerpt) = cursor.item()
|
||||
@@ -6334,7 +6334,7 @@ impl MultiBufferSnapshot {
|
||||
range: &'a Range<Anchor>,
|
||||
include_local: bool,
|
||||
) -> impl 'a + Iterator<Item = (ReplicaId, bool, CursorShape, Selection<Anchor>)> {
|
||||
let mut cursor = self.excerpts.cursor::<ExcerptSummary>(&());
|
||||
let mut cursor = self.excerpts.cursor::<ExcerptSummary>(());
|
||||
let start_locator = self.excerpt_locator_for_id(range.start.excerpt_id);
|
||||
let end_locator = self.excerpt_locator_for_id(range.end.excerpt_id);
|
||||
cursor.seek(start_locator, Bias::Left);
|
||||
@@ -6448,8 +6448,8 @@ impl MultiBufferSnapshot {
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
fn check_invariants(&self) {
|
||||
let excerpts = self.excerpts.items(&());
|
||||
let excerpt_ids = self.excerpt_ids.items(&());
|
||||
let excerpts = self.excerpts.items(());
|
||||
let excerpt_ids = self.excerpt_ids.items(());
|
||||
|
||||
for (ix, excerpt) in excerpts.iter().enumerate() {
|
||||
if ix == 0 {
|
||||
@@ -6476,7 +6476,7 @@ impl MultiBufferSnapshot {
|
||||
"incorrect input summary. expected {:?}, got {:?}. transforms: {:+?}",
|
||||
self.excerpts.summary().text.len,
|
||||
self.diff_transforms.summary().input,
|
||||
self.diff_transforms.items(&()),
|
||||
self.diff_transforms.items(()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6495,7 +6495,7 @@ impl MultiBufferSnapshot {
|
||||
{
|
||||
panic!(
|
||||
"multiple adjacent buffer content transforms with is_inserted_hunk = {inserted_hunk_info:?}. transforms: {:+?}",
|
||||
self.diff_transforms.items(&())
|
||||
self.diff_transforms.items(())
|
||||
);
|
||||
}
|
||||
if summary.len == 0 && !self.is_empty() {
|
||||
@@ -7243,7 +7243,7 @@ impl fmt::Debug for Excerpt {
|
||||
impl sum_tree::Item for Excerpt {
|
||||
type Summary = ExcerptSummary;
|
||||
|
||||
fn summary(&self, _cx: &()) -> Self::Summary {
|
||||
fn summary(&self, _cx: ()) -> Self::Summary {
|
||||
let mut text = self.text_summary;
|
||||
if self.has_trailing_newline {
|
||||
text += TextSummary::from("\n");
|
||||
@@ -7260,7 +7260,7 @@ impl sum_tree::Item for Excerpt {
|
||||
impl sum_tree::Item for ExcerptIdMapping {
|
||||
type Summary = ExcerptId;
|
||||
|
||||
fn summary(&self, _cx: &()) -> Self::Summary {
|
||||
fn summary(&self, _cx: ()) -> Self::Summary {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
@@ -7287,7 +7287,7 @@ impl DiffTransform {
|
||||
impl sum_tree::Item for DiffTransform {
|
||||
type Summary = DiffTransformSummary;
|
||||
|
||||
fn summary(&self, _: &<Self::Summary as sum_tree::Summary>::Context) -> Self::Summary {
|
||||
fn summary(&self, _: <Self::Summary as sum_tree::Summary>::Context<'_>) -> Self::Summary {
|
||||
match self {
|
||||
DiffTransform::BufferContent { summary, .. } => DiffTransformSummary {
|
||||
input: *summary,
|
||||
@@ -7307,83 +7307,77 @@ impl DiffTransformSummary {
|
||||
}
|
||||
}
|
||||
|
||||
impl sum_tree::Summary for DiffTransformSummary {
|
||||
type Context = ();
|
||||
|
||||
fn zero(_: &Self::Context) -> Self {
|
||||
impl sum_tree::ContextLessSummary for DiffTransformSummary {
|
||||
fn zero() -> Self {
|
||||
DiffTransformSummary {
|
||||
input: TextSummary::default(),
|
||||
output: TextSummary::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &Self, _: &Self::Context) {
|
||||
self.input += &summary.input;
|
||||
self.output += &summary.output;
|
||||
fn add_summary(&mut self, other: &Self) {
|
||||
self.input += other.input;
|
||||
self.output += other.output;
|
||||
}
|
||||
}
|
||||
|
||||
impl sum_tree::Summary for ExcerptId {
|
||||
type Context = ();
|
||||
|
||||
fn zero(_cx: &()) -> Self {
|
||||
Default::default()
|
||||
impl sum_tree::ContextLessSummary for ExcerptId {
|
||||
fn zero() -> Self {
|
||||
Self(0)
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, other: &Self, _: &()) {
|
||||
*self = *other;
|
||||
fn add_summary(&mut self, summary: &Self) {
|
||||
*self = cmp::max(*self, *summary);
|
||||
}
|
||||
}
|
||||
|
||||
impl sum_tree::Summary for ExcerptSummary {
|
||||
type Context = ();
|
||||
|
||||
fn zero(_cx: &()) -> Self {
|
||||
Default::default()
|
||||
impl sum_tree::ContextLessSummary for ExcerptSummary {
|
||||
fn zero() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &Self, _: &()) {
|
||||
fn add_summary(&mut self, summary: &Self) {
|
||||
debug_assert!(summary.excerpt_locator > self.excerpt_locator);
|
||||
self.excerpt_locator = summary.excerpt_locator.clone();
|
||||
Summary::add_summary(&mut self.text, &summary.text, &());
|
||||
Summary::add_summary(&mut self.text, &summary.text, ());
|
||||
self.widest_line_number = cmp::max(self.widest_line_number, summary.widest_line_number);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for ExcerptOffset {
|
||||
fn zero(_cx: &()) -> Self {
|
||||
fn zero(_cx: ()) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: ()) {
|
||||
self.value += summary.text.len;
|
||||
}
|
||||
}
|
||||
|
||||
impl sum_tree::SeekTarget<'_, ExcerptSummary, ExcerptSummary> for ExcerptOffset {
|
||||
fn cmp(&self, cursor_location: &ExcerptSummary, _: &()) -> cmp::Ordering {
|
||||
fn cmp(&self, cursor_location: &ExcerptSummary, _: ()) -> cmp::Ordering {
|
||||
Ord::cmp(&self.value, &cursor_location.text.len)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::SeekTarget<'a, ExcerptSummary, Option<&'a Locator>> for Locator {
|
||||
fn cmp(&self, cursor_location: &Option<&'a Locator>, _: &()) -> cmp::Ordering {
|
||||
fn cmp(&self, cursor_location: &Option<&'a Locator>, _: ()) -> cmp::Ordering {
|
||||
Ord::cmp(&Some(self), cursor_location)
|
||||
}
|
||||
}
|
||||
|
||||
impl sum_tree::SeekTarget<'_, ExcerptSummary, ExcerptSummary> for Locator {
|
||||
fn cmp(&self, cursor_location: &ExcerptSummary, _: &()) -> cmp::Ordering {
|
||||
fn cmp(&self, cursor_location: &ExcerptSummary, _: ()) -> cmp::Ordering {
|
||||
Ord::cmp(self, &cursor_location.excerpt_locator)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for ExcerptPoint {
|
||||
fn zero(_cx: &()) -> Self {
|
||||
fn zero(_cx: ()) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: ()) {
|
||||
self.value += summary.text.lines;
|
||||
}
|
||||
}
|
||||
@@ -7391,31 +7385,31 @@ impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for ExcerptPoint {
|
||||
impl<'a, D: TextDimension + Default> sum_tree::Dimension<'a, ExcerptSummary>
|
||||
for ExcerptDimension<D>
|
||||
{
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
ExcerptDimension(D::default())
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: ()) {
|
||||
self.0.add_assign(&D::from_text_summary(&summary.text))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for Option<&'a Locator> {
|
||||
fn zero(_cx: &()) -> Self {
|
||||
fn zero(_cx: ()) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: ()) {
|
||||
*self = Some(&summary.excerpt_locator);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for Option<ExcerptId> {
|
||||
fn zero(_cx: &()) -> Self {
|
||||
fn zero(_cx: ()) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: ()) {
|
||||
*self = Some(summary.excerpt_id);
|
||||
}
|
||||
}
|
||||
@@ -7427,21 +7421,21 @@ struct ExcerptDimension<T>(T);
|
||||
struct OutputDimension<T>(T);
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for ExcerptOffset {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
ExcerptOffset::new(0)
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
self.value += summary.input.len;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for ExcerptPoint {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
ExcerptPoint::new(0, 0)
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
self.value += summary.input.lines;
|
||||
}
|
||||
}
|
||||
@@ -7449,7 +7443,7 @@ impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for ExcerptPoint {
|
||||
impl<D: TextDimension + Ord> sum_tree::SeekTarget<'_, DiffTransformSummary, DiffTransformSummary>
|
||||
for ExcerptDimension<D>
|
||||
{
|
||||
fn cmp(&self, cursor_location: &DiffTransformSummary, _: &()) -> cmp::Ordering {
|
||||
fn cmp(&self, cursor_location: &DiffTransformSummary, _: ()) -> cmp::Ordering {
|
||||
Ord::cmp(&self.0, &D::from_text_summary(&cursor_location.input))
|
||||
}
|
||||
}
|
||||
@@ -7457,17 +7451,17 @@ impl<D: TextDimension + Ord> sum_tree::SeekTarget<'_, DiffTransformSummary, Diff
|
||||
impl<D: TextDimension + Ord> sum_tree::SeekTarget<'_, DiffTransformSummary, DiffTransforms<D>>
|
||||
for ExcerptDimension<D>
|
||||
{
|
||||
fn cmp(&self, cursor_location: &DiffTransforms<D>, _: &()) -> cmp::Ordering {
|
||||
fn cmp(&self, cursor_location: &DiffTransforms<D>, _: ()) -> cmp::Ordering {
|
||||
Ord::cmp(&self.0, &cursor_location.excerpt_dimension.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, D: TextDimension> sum_tree::Dimension<'a, DiffTransformSummary> for ExcerptDimension<D> {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
ExcerptDimension(D::default())
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
self.0.add_assign(&D::from_text_summary(&summary.input))
|
||||
}
|
||||
}
|
||||
@@ -7475,47 +7469,47 @@ impl<'a, D: TextDimension> sum_tree::Dimension<'a, DiffTransformSummary> for Exc
|
||||
impl<D: TextDimension + Ord> sum_tree::SeekTarget<'_, DiffTransformSummary, DiffTransforms<D>>
|
||||
for OutputDimension<D>
|
||||
{
|
||||
fn cmp(&self, cursor_location: &DiffTransforms<D>, _: &()) -> cmp::Ordering {
|
||||
fn cmp(&self, cursor_location: &DiffTransforms<D>, _: ()) -> cmp::Ordering {
|
||||
Ord::cmp(&self.0, &cursor_location.output_dimension.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, D: TextDimension> sum_tree::Dimension<'a, DiffTransformSummary> for OutputDimension<D> {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
OutputDimension(D::default())
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
self.0.add_assign(&D::from_text_summary(&summary.output))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for TextSummary {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
TextSummary::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
*self += summary.output
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for usize {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
0
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
*self += summary.output.len
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for Point {
|
||||
fn zero(_: &()) -> Self {
|
||||
fn zero(_: ()) -> Self {
|
||||
Point::new(0, 0)
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: &()) {
|
||||
fn add_summary(&mut self, summary: &'a DiffTransformSummary, _: ()) {
|
||||
*self += summary.output.lines
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user