Skip to content

Commit

Permalink
perf: use range for memcspn (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf authored Feb 6, 2023
1 parent c31d31f commit 50e7512
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/ascii.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
macro_rules! memcpsn {
($value:ident, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
{
let mut i = 0;
loop {
if i == $value.len() {
break None;
}
let mut result = None;
for i in 0..$value.len() {
if matches!($value[i], $( $pattern )|+ $( if $guard )?) {
break Some(i);
result = Some(i);
break;
}
i += 1;
}
result
}
};
}
Expand Down

0 comments on commit 50e7512

Please sign in to comment.