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 
This commit is contained in:
Élie ROUDNINSKI 2022-07-05 19:31:23 +02:00 committed by GitHub
parent 0c2774894a
commit 5e98788947
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

@ -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

@ -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