diff --git a/src/backtrack.rs b/src/backtrack.rs index 4296e63e3b..918610a504 100644 --- a/src/backtrack.rs +++ b/src/backtrack.rs @@ -233,7 +233,7 @@ impl<'r, 't, 'c> Backtrack<'r, 't, 'c> { } } Ranges(ref inst) => { - if inst.matches(at.char()).is_some() { + if inst.matches(at.char()) { pc += 1; at = self.input.at(at.next_pos()); } else { diff --git a/src/nfa.rs b/src/nfa.rs index 2759dabeb2..88a7711e22 100644 --- a/src/nfa.rs +++ b/src/nfa.rs @@ -166,7 +166,7 @@ impl<'r, 't> Nfa<'r, 't> { false } Ranges(ref inst) => { - if inst.matches(at.char()).is_some() { + if inst.matches(at.char()) { self.add(nlist, thread_caps, pc+1, at_next); } false diff --git a/src/program.rs b/src/program.rs index ae0a4fd22d..2bd54bdf71 100644 --- a/src/program.rs +++ b/src/program.rs @@ -93,16 +93,16 @@ impl CharRanges { /// Tests whether the given input character matches this instruction. #[inline(always)] // About ~5-15% more throughput then `#[inline]` - pub fn matches(&self, c: Char) -> Option { + pub fn matches(&self, c: Char) -> bool { // This speeds up the `match_class_unicode` benchmark by checking // some common cases quickly without binary search. e.g., Matching // a Unicode class on predominantly ASCII text. - for (i, r) in self.ranges.iter().take(4).enumerate() { + for r in self.ranges.iter().take(4) { if c < r.0 { - return None; + return false; } if c <= r.1 { - return Some(i); + return true; } } self.ranges.binary_search_by(|r| { @@ -113,7 +113,7 @@ impl CharRanges { } else { Ordering::Equal } - }).ok() + }).is_ok() } }