From c569b009631db6872ac05cf2d70aea751115b4cc Mon Sep 17 00:00:00 2001 From: dan <70999565+belovdv@users.noreply.github.com> Date: Tue, 23 Jun 2026 18:39:34 +0300 Subject: [PATCH] [rust] Deserialization optimization --- rust/lira/src/ir_ser_txt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/lira/src/ir_ser_txt.rs b/rust/lira/src/ir_ser_txt.rs index 70b4477..781fcd5 100644 --- a/rust/lira/src/ir_ser_txt.rs +++ b/rust/lira/src/ir_ser_txt.rs @@ -15,9 +15,9 @@ impl std::fmt::Display for Shape { impl Shape { pub fn parse(s: &str) -> anyhow::Result { - let re = Regex::new(r"^(\d+)(.*)$").unwrap(); + static RE: LazyLock = LazyLock::new(|| Regex::new(r"^(\d+)(.*)$").unwrap()); let err = || anyhow::anyhow!("failed to parse {s}"); - let caps = re.captures(s).ok_or_else(err)?; + let caps = RE.captures(s).ok_or_else(err)?; Ok(Self { lanes_base: caps[1].parse()?, lanes_mult: (!caps[2].is_empty()).then(|| caps[2].to_string()),