From baff717e7f927ce710c5ce2741570e1dfe1fc38b Mon Sep 17 00:00:00 2001 From: daisuke8000 Date: Sun, 5 Jul 2026 17:44:02 +0900 Subject: [PATCH] Use eq_ignore_ascii_case in exit_watch level rank (DSK-129) Avoid per-line String allocation when ranking LogLevel::Other labels for --exit-on-level. Co-authored-by: Cursor --- .../rustern-core/src/pipeline/exit_watch.rs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/crates/rustern-core/src/pipeline/exit_watch.rs b/crates/rustern-core/src/pipeline/exit_watch.rs index 600c4cb..781b229 100644 --- a/crates/rustern-core/src/pipeline/exit_watch.rs +++ b/crates/rustern-core/src/pipeline/exit_watch.rs @@ -47,14 +47,24 @@ fn event_level_rank(level: &LogLevel) -> u8 { LogLevel::Info => 2, LogLevel::Warn => 3, LogLevel::Error => 4, - LogLevel::Other(s) => match s.to_ascii_lowercase().as_str() { - "error" | "err" | "fatal" => 4, - "warn" | "warning" => 3, - "info" => 2, - "debug" => 1, - "trace" => 0, - _ => 2, - }, + LogLevel::Other(s) => { + if s.eq_ignore_ascii_case("error") + || s.eq_ignore_ascii_case("err") + || s.eq_ignore_ascii_case("fatal") + { + 4 + } else if s.eq_ignore_ascii_case("warn") || s.eq_ignore_ascii_case("warning") { + 3 + } else if s.eq_ignore_ascii_case("info") { + 2 + } else if s.eq_ignore_ascii_case("debug") { + 1 + } else if s.eq_ignore_ascii_case("trace") { + 0 + } else { + 2 + } + } } }