Optimize summaries_for_anchors when MultiBuffer is a singleton

This commit is contained in:
Antonio Scandurra 2022-02-03 11:22:55 +01:00
parent ab26a175a4
commit 7865c32727

View File

@ -1543,6 +1543,13 @@ impl MultiBufferSnapshot {
D: TextDimension + Ord + Sub<D, Output = D>,
I: 'a + IntoIterator<Item = &'a Anchor>,
{
if let Some(excerpt) = self.as_singleton() {
return excerpt
.buffer
.summaries_for_anchors(anchors.into_iter().map(|a| &a.text_anchor))
.collect();
}
let mut anchors = anchors.into_iter().peekable();
let mut cursor = self.excerpts.cursor::<ExcerptSummary>();
let mut summaries = Vec::new();