From 7402238d9d4ca01ac7e6c0bd8261b363b06e0602 Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 16 Aug 2022 14:28:00 -0500 Subject: [PATCH] cache lex_matchers --- clarity/src/vm/ast/parser/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/clarity/src/vm/ast/parser/mod.rs b/clarity/src/vm/ast/parser/mod.rs index 6782d69a5..cbf014312 100644 --- a/clarity/src/vm/ast/parser/mod.rs +++ b/clarity/src/vm/ast/parser/mod.rs @@ -124,14 +124,8 @@ lazy_static! { ); pub static ref CLARITY_NAME_REGEX: String = format!(r#"([[:word:]]|[-!?+<>=/*]){{1,{}}}"#, MAX_STRING_LEN); -} -pub fn lex(input: &str) -> ParseResult> { - // Aaron: I'd like these to be static, but that'd require using - // lazy_static (or just hand implementing that), and I'm not convinced - // it's worth either (1) an extern macro, or (2) the complexity of hand implementing. - - let lex_matchers: &[LexMatcher] = &[ + static ref lex_matchers: Vec = vec![ LexMatcher::new( r##"u"(?P((\\")|([[ -~]&&[^"]]))*)""##, TokenType::StringUTF8Literal, @@ -187,7 +181,9 @@ pub fn lex(input: &str) -> ParseResult> { TokenType::Variable, ), ]; +} +pub fn lex(input: &str) -> ParseResult> { let mut context = LexContext::ExpectNothing; let mut line_indices = get_lines_at(input);