Skip to content

Commit 36a049b

Browse files
idekaBurntSushi
authored andcommitted
automata: add DFA::set_prefilter method to the DFA types
Closes #1225
1 parent ab88aa5 commit 36a049b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

regex-automata/src/dfa/dense.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,19 @@ impl<'a> DFA<&'a [u32]> {
24692469
}
24702470
}
24712471

2472+
/// Other routines that work for all `T`.
2473+
impl<T> DFA<T> {
2474+
/// Set or unset the prefilter attached to this DFA.
2475+
///
2476+
/// This is useful when one has deserialized a DFA from `&[u8]`.
2477+
/// Deserialization does not currently include prefilters, so if you
2478+
/// want prefilter acceleration, you'll need to rebuild it and attach
2479+
/// it here.
2480+
pub fn set_prefilter(&mut self, prefilter: Option<Prefilter>) {
2481+
self.pre = prefilter
2482+
}
2483+
}
2484+
24722485
// The following methods implement mutable routines on the internal
24732486
// representation of a DFA. As such, we must fix the first type parameter to a
24742487
// `Vec<u32>` since a generic `T: AsRef<[u32]>` does not permit mutation. We

regex-automata/src/dfa/sparse.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,19 @@ impl<'a> DFA<&'a [u8]> {
10711071
}
10721072
}
10731073

1074+
/// Other routines that work for all `T`.
1075+
impl<T> DFA<T> {
1076+
/// Set or unset the prefilter attached to this DFA.
1077+
///
1078+
/// This is useful when one has deserialized a DFA from `&[u8]`.
1079+
/// Deserialization does not currently include prefilters, so if you
1080+
/// want prefilter acceleration, you'll need to rebuild it and attach
1081+
/// it here.
1082+
pub fn set_prefilter(&mut self, prefilter: Option<Prefilter>) {
1083+
self.pre = prefilter
1084+
}
1085+
}
1086+
10741087
impl<T: AsRef<[u8]>> fmt::Debug for DFA<T> {
10751088
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10761089
writeln!(f, "sparse::DFA(")?;

0 commit comments

Comments
 (0)