on master help sign in
Use binary_search when looking up diagnostics

They're sorted by range so they should also be sorted by line

commita2b22ec15207926acf9bbf6617492925a6e50d27 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 6 Dec 2021, 12:48 (5 years ago) parentcab0909
1 file changed+1−1
helix-view/src/gutter.rs+1−1
helix-view/src/gutter.rs+1−1
@@ -22,7 +22,7 @@ pub fn diagnostic<'doc>(
2222
2323 Box::new(move |line: usize, _selected: bool, out: &mut String| {
2424 use helix_core::diagnostic::Severity;
25− if let Some(diagnostic) = diagnostics.iter().find(|d| d.line == line) {
25+ if let Some(diagnostic) = diagnostics.binary_search_by_key(&line, |d| d.line) {
2626 write!(out, "●").unwrap();
2727 return Some(match diagnostic.severity {
2828 Some(Severity::Error) => error,