From 7865c327276d4eb7d97f431cc4b64b60f5894adb Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 3 Feb 2022 11:22:55 +0100 Subject: [PATCH] Optimize `summaries_for_anchors` when `MultiBuffer` is a singleton --- crates/editor/src/multi_buffer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index 2bdf819956..1904e00edc 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -1543,6 +1543,13 @@ impl MultiBufferSnapshot { D: TextDimension + Ord + Sub, I: 'a + IntoIterator, { + 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::(); let mut summaries = Vec::new();