Skip to content

Commit

Permalink
chore(lib): rewrite using ClassUnicode methods
Browse files Browse the repository at this point in the history
As suggested by @RustyYato
  • Loading branch information
jeertmans committed Feb 16, 2024
1 parent 0aa58a0 commit 80bd23f
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions logos-codegen/src/graph/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,15 @@ impl<Leaf: Disambiguate + Debug> Graph<Leaf> {
}
}

#[inline]
fn is_ascii(class: &ClassUnicode) -> bool {
class.iter().all(|range| {
let start = range.start() as u32;
let end = range.end() as u32;

start < 128 && end < 128
})
class.is_ascii()
}

#[inline]
fn is_one_ascii(class: &ClassUnicode) -> bool {
if class.ranges().len() != 1 {
return false;
}

let range = &class.ranges()[0];
let start = range.start() as u32;
let end = range.end() as u32;

start < 128 && end < 128
let ranges = class.ranges();
ranges.len() == 1 && ranges[0].end() < '\x7F'
}

#[cfg(test)]
Expand Down

0 comments on commit 80bd23f

Please sign in to comment.