feat: lazy regex
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::fmt::{Debug, Formatter, Result};
|
||||
|
||||
use ecow::EcoString;
|
||||
|
||||
use crate::ty::internal::Const;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||
use std::ops::Deref;
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use derive_more::Constructor;
|
||||
use ecow::EcoString;
|
||||
use regex::Regex;
|
||||
@@ -39,9 +41,10 @@ impl Display for Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
static REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"^[a-zA-Z\_][a-zA-Z0-9\_\'\-]*$"#).unwrap());
|
||||
impl Symbol {
|
||||
fn normal(&self) -> bool {
|
||||
!Regex::new(r#"^[a-zA-Z\_][a-zA-Z0-9\_\'\-]*$"#).unwrap().is_match(self)
|
||||
!REGEX.is_match(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user