Skip to content

Commit

Permalink
use memrchr instead of memchr_iter().next_back()
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 20, 2023
1 parent 16781cd commit a73092a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,16 @@ impl Opts for AsciiCandidateOpts {

let query_byte = query_ch as u8;

let offset = if self.is_case_sensitive
|| !query_byte.is_ascii_alphabetic()
{
memchr::memchr_iter(query_byte, candidate.as_bytes()).next_back()
} else {
memchr::memchr2_iter(
query_byte,
ascii_letter_flip_case(query_byte),
candidate.as_bytes(),
)
.next_back()
}?;
let offset =
if self.is_case_sensitive || !query_byte.is_ascii_alphabetic() {
memchr::memrchr(query_byte, candidate.as_bytes())
} else {
memchr::memrchr2(
query_byte,
ascii_letter_flip_case(query_byte),
candidate.as_bytes(),
)
}?;

Some((offset, 1))
}
Expand Down

0 comments on commit a73092a

Please sign in to comment.