diff --git a/Cargo.toml b/Cargo.toml index c17ae8232c..c2aa8dee9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,6 @@ getset = "0.1.1" strum = "0.26.2" strum_macros = "0.26.2" regex = "~1.10.5" -once_cell = "~1.19.0" [dev-dependencies] tempfile = "3.2.0" diff --git a/src/runtime/process.rs b/src/runtime/process.rs index 20d197a1c1..79ef8544fc 100644 --- a/src/runtime/process.rs +++ b/src/runtime/process.rs @@ -4,10 +4,10 @@ use crate::{ }; use derive_builder::Builder; use getset::{CopyGetters, Getters, MutGetters, Setters}; -use once_cell::sync::Lazy; use regex::Regex; use serde::{de, Deserialize, Deserializer, Serialize}; use std::path::PathBuf; +use std::sync::OnceLock; use strum_macros::{Display as StrumDisplay, EnumString}; #[derive( @@ -623,12 +623,16 @@ where Ok(value) } -static EXEC_CPU_AFFINITY_REGEX: Lazy = Lazy::new(|| { - Regex::new(r"^(\d+(-\d+)?)(,\d+(-\d+)?)*$").expect("Failed to create regex for execCPUAffinity") -}); +fn exec_cpu_affinity_regex() -> &'static Regex { + static EXEC_CPU_AFFINITY_REGEX: OnceLock = OnceLock::new(); + EXEC_CPU_AFFINITY_REGEX.get_or_init(|| { + Regex::new(r"^(\d+(-\d+)?)(,\d+(-\d+)?)*$") + .expect("Failed to create regex for execCPUAffinity") + }) +} fn validate_cpu_affinity(s: &str) -> Result<(), String> { - if !EXEC_CPU_AFFINITY_REGEX.is_match(s) { + if !exec_cpu_affinity_regex().is_match(s) { return Err(format!("Invalid execCPUAffinity format: {}", s)); }