Mercurial > forks > helix
changeset 6781:07045662b7d8
perf(statusline): reorder match and specify `u32` for `workspace_diagnostics` (#13512)
author | RoloEdits <RoloEdits@gmail.com> |
---|---|
date | Mon, 12 May 2025 06:27:04 -0700 |
parents | f9d9d980e4c7 |
children | fb32a960a8b4 |
files | helix-term/src/ui/statusline.rs |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/helix-term/src/ui/statusline.rs Mon May 12 15:23:59 2025 +0200 +++ b/helix-term/src/ui/statusline.rs Mon May 12 06:27:04 2025 -0700 @@ -287,14 +287,19 @@ { use helix_core::diagnostic::Severity; let (hints, info, warnings, errors) = context.editor.diagnostics.values().flatten().fold( - (0, 0, 0, 0), + (0u32, 0u32, 0u32, 0u32), |mut counts, (diag, _)| { match diag.severity { - Some(DiagnosticSeverity::HINT) | None => counts.0 += 1, - Some(DiagnosticSeverity::INFORMATION) => counts.1 += 1, + // PERF: For large workspace diagnostics, this loop can be very tight. + // + // Most often the diagnostics will be for warnings and errors. + // Errors should tend to be fixed fast, leaving warnings as the most common. Some(DiagnosticSeverity::WARNING) => counts.2 += 1, Some(DiagnosticSeverity::ERROR) => counts.3 += 1, - _ => {} + Some(DiagnosticSeverity::HINT) => counts.0 += 1, + Some(DiagnosticSeverity::INFORMATION) => counts.1 += 1, + // Fallback to `hint`. + _ => counts.0 += 1, } counts },