Skip to content

Commit 5e98788

Browse files
authored
perf: use is_match_at instead of shortest_match_at
Local benchmarks show up to 15% reduction in terms of number of retired instructions executed and at least 5% reduction in terms of CPU time. This is basically a bit of a manual inlining here, instead of doing more redirection. PR #788
1 parent 0c27748 commit 5e98788

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/re_bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl Regex {
578578
/// context into consideration. For example, the `\A` anchor can only
579579
/// match when `start == 0`.
580580
pub fn is_match_at(&self, text: &[u8], start: usize) -> bool {
581-
self.shortest_match_at(text, start).is_some()
581+
self.0.searcher().is_match_at(text, start)
582582
}
583583

584584
/// Returns the same as find, but starts the search at the given

src/re_unicode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ impl Regex {
636636
/// context into consideration. For example, the `\A` anchor can only
637637
/// match when `start == 0`.
638638
pub fn is_match_at(&self, text: &str, start: usize) -> bool {
639-
self.shortest_match_at(text, start).is_some()
639+
self.0.searcher_str().is_match_at(text, start)
640640
}
641641

642642
/// Returns the same as find, but starts the search at the given

0 commit comments

Comments
 (0)