Change summary
crates/multi_buffer/src/multi_buffer.rs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
Detailed changes
@@ -799,6 +799,7 @@ pub struct ExcerptSummary {
excerpt_locator: Locator,
widest_line_number: u32,
text: MBTextSummary,
+ count: usize,
}
#[derive(Debug, Clone)]
@@ -2046,12 +2047,10 @@ impl MultiBuffer {
}
pub fn excerpt_ids(&self) -> Vec<ExcerptId> {
- self.snapshot
- .borrow()
- .excerpts
- .iter()
- .map(|entry| entry.id)
- .collect()
+ let snapshot = self.snapshot.borrow();
+ let mut ids = Vec::with_capacity(snapshot.excerpts.summary().count);
+ ids.extend(snapshot.excerpts.iter().map(|entry| entry.id));
+ ids
}
pub fn excerpt_containing(
@@ -7746,6 +7745,7 @@ impl sum_tree::Item for Excerpt {
excerpt_locator: self.locator.clone(),
widest_line_number: self.max_buffer_row,
text: text.into(),
+ count: 1,
}
}
}
@@ -7840,6 +7840,7 @@ impl sum_tree::ContextLessSummary for ExcerptSummary {
self.excerpt_locator = summary.excerpt_locator.clone();
self.text += summary.text;
self.widest_line_number = cmp::max(self.widest_line_number, summary.widest_line_number);
+ self.count += summary.count;
}
}