Skip to content

Commit

Permalink
[dictionary-builder] compile tag regexes outside line loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Enet4 committed Dec 7, 2024
1 parent d5ea19b commit ee526df
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions devtools/dictionary-builder/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ pub fn run(args: DataElementApp) -> Result<()> {
fn parse_entries<R: BufRead>(source: R) -> Result<Vec<Entry>> {
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('#') {
Expand Down Expand Up @@ -113,11 +118,6 @@ fn parse_entries<R: BufRead>(source: R) -> Result<Vec<Entry>> {

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 {
Expand Down

0 comments on commit ee526df

Please sign in to comment.