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()),