From 3e478d540b27d2505dd3709c2eb8eae6dcd5a0bc Mon Sep 17 00:00:00 2001 From: 1toldyou <86680163+1toldyou@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:47:34 -0700 Subject: [PATCH] wrap the regex for detecting timestamp with lazy_static! --- src/module/recorder.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/module/recorder.rs b/src/module/recorder.rs index dbb4092..ac5f91e 100644 --- a/src/module/recorder.rs +++ b/src/module/recorder.rs @@ -480,9 +480,11 @@ impl YTAStatus { // New versions of ytarchive prepend a timestamp to the output // Sample line // 2024/04/16 16:25:31 - let timestamp_re = Regex::new(r"^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}") - .expect("Failed to compile regex for detecting yta output timestamp"); - let line = if line.len() > 20 && timestamp_re.is_match(line) { + lazy_static! { + static ref TIMESTAMP_RE: Regex = Regex::new(r"^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}") + .expect("Failed to compile regex for detecting yta output timestamp"); + } + let line = if line.len() > 20 && TIMESTAMP_RE.is_match(line) { line[20..].trim() } else { line