Skip to content

Commit

Permalink
automata/meta: force some prefilter inlining
Browse files Browse the repository at this point in the history
In some ad hoc profiling, I noticed an extra function call that really
didn't need to be there.
  • Loading branch information
BurntSushi committed Oct 14, 2023
1 parent 25ad29f commit cfd0ca2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions regex-automata/src/meta/strategy.rs
Expand Up @@ -353,6 +353,7 @@ impl Pre<()> {
// strategy when len(patterns)==1 if the number of literals is large. In that
// case, literal extraction gives up and will return an infinite set.)
impl<P: PrefilterI> Strategy for Pre<P> {
#[cfg_attr(feature = "perf-inline", inline(always))]
fn group_info(&self) -> &GroupInfo {
&self.group_info
}
Expand All @@ -378,6 +379,7 @@ impl<P: PrefilterI> Strategy for Pre<P> {
self.pre.memory_usage()
}

#[cfg_attr(feature = "perf-inline", inline(always))]
fn search(&self, _cache: &mut Cache, input: &Input<'_>) -> Option<Match> {
if input.is_done() {
return None;
Expand All @@ -393,6 +395,7 @@ impl<P: PrefilterI> Strategy for Pre<P> {
.map(|sp| Match::new(PatternID::ZERO, sp))
}

#[cfg_attr(feature = "perf-inline", inline(always))]
fn search_half(
&self,
cache: &mut Cache,
Expand All @@ -401,10 +404,12 @@ impl<P: PrefilterI> Strategy for Pre<P> {
self.search(cache, input).map(|m| HalfMatch::new(m.pattern(), m.end()))
}

#[cfg_attr(feature = "perf-inline", inline(always))]
fn is_match(&self, cache: &mut Cache, input: &Input<'_>) -> bool {
self.search(cache, input).is_some()
}

#[cfg_attr(feature = "perf-inline", inline(always))]
fn search_slots(
&self,
cache: &mut Cache,
Expand All @@ -421,6 +426,7 @@ impl<P: PrefilterI> Strategy for Pre<P> {
Some(m.pattern())
}

#[cfg_attr(feature = "perf-inline", inline(always))]
fn which_overlapping_matches(
&self,
cache: &mut Cache,
Expand Down

0 comments on commit cfd0ca2

Please sign in to comment.