Skip to content

Commit d23fe1d

Browse files
committed
Merge pull request #114 from SeanRBurton/master
minor tweak
2 parents f9a7541 + 2ec6a64 commit d23fe1d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/backtrack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'r, 't, 'c> Backtrack<'r, 't, 'c> {
233233
}
234234
}
235235
Ranges(ref inst) => {
236-
if inst.matches(at.char()).is_some() {
236+
if inst.matches(at.char()) {
237237
pc += 1;
238238
at = self.input.at(at.next_pos());
239239
} else {

src/nfa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'r, 't> Nfa<'r, 't> {
166166
false
167167
}
168168
Ranges(ref inst) => {
169-
if inst.matches(at.char()).is_some() {
169+
if inst.matches(at.char()) {
170170
self.add(nlist, thread_caps, pc+1, at_next);
171171
}
172172
false

src/program.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ impl CharRanges {
9393

9494
/// Tests whether the given input character matches this instruction.
9595
#[inline(always)] // About ~5-15% more throughput then `#[inline]`
96-
pub fn matches(&self, c: Char) -> Option<usize> {
96+
pub fn matches(&self, c: Char) -> bool {
9797
// This speeds up the `match_class_unicode` benchmark by checking
9898
// some common cases quickly without binary search. e.g., Matching
9999
// a Unicode class on predominantly ASCII text.
100-
for (i, r) in self.ranges.iter().take(4).enumerate() {
100+
for r in self.ranges.iter().take(4) {
101101
if c < r.0 {
102-
return None;
102+
return false;
103103
}
104104
if c <= r.1 {
105-
return Some(i);
105+
return true;
106106
}
107107
}
108108
self.ranges.binary_search_by(|r| {
@@ -113,7 +113,7 @@ impl CharRanges {
113113
} else {
114114
Ordering::Equal
115115
}
116-
}).ok()
116+
}).is_ok()
117117
}
118118
}
119119

0 commit comments

Comments
 (0)