ui: Since diagnostics are sorted, we can use binary search
commit28fd704bce2fec56e46991b26eed5a17e519e6bd
authorBlaž Hrastnik <blaz@mxxn.io>
dateMon 22 Nov 2021, 11:26 (5 years ago)
parentb55ca8f
helix-term/src/ui/editor.rs+2−1
@@ -482,7 +482,8 @@ impl EditorView {
482482
483483 for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
484484 use helix_core::diagnostic::Severity;
485− if let Some(diagnostic) = doc.diagnostics().iter().find(|d| d.line == line) {
485+ if let Ok(diagnostic) = doc.diagnostics().binary_search_by_key(&line, |d| d.line) {
486+ let diagnostic = &doc.diagnostics()[diagnostic];
486487 surface.set_stringn(
487488 viewport.x,
488489 viewport.y + i as u16,