From ee526dfa9c3b4e4166f180a313ea7a8aba4fd606 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 7 Dec 2024 12:38:58 +0000 Subject: [PATCH] [dictionary-builder] compile tag regexes outside line loop --- devtools/dictionary-builder/src/tags.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/devtools/dictionary-builder/src/tags.rs b/devtools/dictionary-builder/src/tags.rs index 1743ee456..048f29af1 100644 --- a/devtools/dictionary-builder/src/tags.rs +++ b/devtools/dictionary-builder/src/tags.rs @@ -84,6 +84,11 @@ pub fn run(args: DataElementApp) -> Result<()> { fn parse_entries(source: R) -> Result> { let mut result = vec![]; + let regex_tag = Regex::new(r"^\(([0-9A-F]{4}),([0-9A-F]{4})\)$")?; + let regex_tag_group100 = Regex::new(r"^\(([0-9A-F]{2})00-[0-9A-F]{2}FF,([0-9A-F]{4})\)$")?; + let regex_tag_element100 = + Regex::new(r"^\(([0-9A-F]{4}),([0-9A-F]{2})00-[0-9A-F]{2}FF\)$")?; + for line in source.lines() { let line = line?; if line.starts_with('#') { @@ -113,11 +118,6 @@ fn parse_entries(source: R) -> Result> { let tag = parts[0].to_string(); - let regex_tag = Regex::new(r"^\(([0-9A-F]{4}),([0-9A-F]{4})\)$")?; - let regex_tag_group100 = Regex::new(r"^\(([0-9A-F]{2})00-[0-9A-F]{2}FF,([0-9A-F]{4})\)$")?; - let regex_tag_element100 = - Regex::new(r"^\(([0-9A-F]{4}),([0-9A-F]{2})00-[0-9A-F]{2}FF\)$")?; - let cap = regex_tag.captures(tag.as_str()); let tag_type; let tag_declaration = if let Some(cap) = cap {