mirror of
https://gitee.com/openharmony/third_party_rust_regex
synced 2025-04-08 05:01:36 +00:00
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
This commit is contained in:
parent
0c2774894a
commit
5e98788947
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user