Skip to content

Commit 3127e3b

Browse files
committed
regex: use new 'which_captures' knob for RegexSet
While this reduces memory usage by half, unfortunately, it's still quite a bit more than memory usage prior to regex 1.9. This is because we are still allocating room to store two offsets per regex for a rather large regex.
1 parent 04b11b6 commit 3127e3b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/builders.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use alloc::{
2828
vec::Vec,
2929
};
3030

31-
use regex_automata::{meta, util::syntax, MatchKind};
31+
use regex_automata::{
32+
meta, nfa::thompson::WhichCaptures, util::syntax, MatchKind,
33+
};
3234

3335
use crate::error::Error;
3436

@@ -100,8 +102,12 @@ impl Builder {
100102
}
101103

102104
fn build_many_string(&self) -> Result<crate::RegexSet, Error> {
103-
let metac =
104-
self.metac.clone().match_kind(MatchKind::All).utf8_empty(true);
105+
let metac = self
106+
.metac
107+
.clone()
108+
.match_kind(MatchKind::All)
109+
.utf8_empty(true)
110+
.which_captures(WhichCaptures::Implicit);
105111
let syntaxc = self.syntaxc.clone().utf8(true);
106112
let patterns = Arc::from(self.pats.as_slice());
107113
meta::Builder::new()
@@ -113,8 +119,12 @@ impl Builder {
113119
}
114120

115121
fn build_many_bytes(&self) -> Result<crate::bytes::RegexSet, Error> {
116-
let metac =
117-
self.metac.clone().match_kind(MatchKind::All).utf8_empty(false);
122+
let metac = self
123+
.metac
124+
.clone()
125+
.match_kind(MatchKind::All)
126+
.utf8_empty(false)
127+
.which_captures(WhichCaptures::Implicit);
118128
let syntaxc = self.syntaxc.clone().utf8(false);
119129
let patterns = Arc::from(self.pats.as_slice());
120130
meta::Builder::new()

0 commit comments

Comments
 (0)