mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Reuse CompileSet() instead of || string formatting
This commit is contained in:
parent
61fcca8482
commit
b55e1a122e
4 changed files with 14 additions and 28 deletions
19
src/RE.cc
19
src/RE.cc
|
@ -172,6 +172,10 @@ bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx
|
|||
dfa = new DFA_Machine(nfa, EC());
|
||||
ecs = EC()->EquivClasses();
|
||||
|
||||
// dfa took ownership
|
||||
Unref(nfa);
|
||||
nfa = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -455,13 +459,16 @@ bool RE_Matcher::Compile(bool lazy) { return re_anywhere->Compile(lazy) && re_ex
|
|||
RE_DisjunctiveMatcher::RE_DisjunctiveMatcher(const std::vector<const RE_Matcher*>& REs) {
|
||||
matcher = std::make_unique<detail::Specific_RE_Matcher>(detail::MATCH_EXACTLY);
|
||||
|
||||
std::string disjunction;
|
||||
for ( auto re : REs )
|
||||
disjunction += std::string("||") + re->PatternText();
|
||||
zeek::detail::string_list sl;
|
||||
zeek::detail::int_list il;
|
||||
|
||||
matcher->SetPat(disjunction.c_str());
|
||||
auto status = matcher->Compile();
|
||||
ASSERT(status);
|
||||
for ( const auto* re : REs ) {
|
||||
sl.push_back(const_cast<char*>(re->PatternText()));
|
||||
il.push_back(sl.size());
|
||||
}
|
||||
|
||||
if ( ! matcher->CompileSet(sl, il) )
|
||||
reporter->FatalError("failed compile set for disjunctive matcher");
|
||||
}
|
||||
|
||||
void RE_DisjunctiveMatcher::Match(const String* s, std::vector<int>& matches) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue