Avoid unnecessary conversion to offsets in diagnostics_in_range

This commit is contained in:
Antonio Scandurra 2021-10-29 14:41:41 +02:00
parent 78c158e1a4
commit 9c1b01521a

View file

@ -735,12 +735,11 @@ impl Buffer {
Ok(()) Ok(())
} }
pub fn diagnostics_in_range<'a, T: ToOffset>( pub fn diagnostics_in_range<'a, T: 'a + ToOffset>(
&'a self, &'a self,
range: Range<T>, range: Range<T>,
) -> impl Iterator<Item = Diagnostic> + 'a { ) -> impl Iterator<Item = Diagnostic> + 'a {
let content = self.content(); let content = self.content();
let range = range.start.to_offset(&content)..range.end.to_offset(&content);
self.diagnostics self.diagnostics
.intersecting_ranges(range, content, true) .intersecting_ranges(range, content, true)
.map(move |(_, range, (severity, message))| Diagnostic { .map(move |(_, range, (severity, message))| Diagnostic {