Skip to content

Commit

Permalink
perf: use is_match_at instead of shortest_match_at
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marmeladema committed Jul 5, 2022
1 parent 0c27748 commit 5e98788
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/re_bytes.rs
Expand Up @@ -578,7 +578,7 @@ impl Regex {
/// context into consideration. For example, the `\A` anchor can only
/// match when `start == 0`.
pub fn is_match_at(&self, text: &[u8], start: usize) -> bool {
self.shortest_match_at(text, start).is_some()
self.0.searcher().is_match_at(text, start)
}

/// Returns the same as find, but starts the search at the given
Expand Down
2 changes: 1 addition & 1 deletion src/re_unicode.rs
Expand Up @@ -636,7 +636,7 @@ impl Regex {
/// context into consideration. For example, the `\A` anchor can only
/// match when `start == 0`.
pub fn is_match_at(&self, text: &str, start: usize) -> bool {
self.shortest_match_at(text, start).is_some()
self.0.searcher_str().is_match_at(text, start)
}

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

0 comments on commit 5e98788

Please sign in to comment.