MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Compile

Method Compile

extern/re2/re2/set.cc:94–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94bool RE2::Set::Compile() {
95 if (compiled_) {
96 LOG(DFATAL) << "RE2::Set::Compile() called more than once";
97 return false;
98 }
99 compiled_ = true;
100 size_ = static_cast<int>(elem_.size());
101
102 // Sort the elements by their patterns. This is good enough for now
103 // until we have a Regexp comparison function. (Maybe someday...)
104 std::sort(elem_.begin(), elem_.end(),
105 [](const Elem& a, const Elem& b) -> bool {
106 return a.first < b.first;
107 });
108
109 PODArray<re2::Regexp*> sub(size_);
110 for (int i = 0; i < size_; i++)
111 sub[i] = elem_[i].second;
112 elem_.clear();
113 elem_.shrink_to_fit();
114
115 Regexp::ParseFlags pf = static_cast<Regexp::ParseFlags>(
116 options_.ParseFlags());
117 re2::Regexp* re = re2::Regexp::Alternate(sub.data(), size_, pf);
118
119 prog_.reset(Prog::CompileSet(re, anchor_, options_.max_mem()));
120 re->Decref();
121 return prog_ != nullptr;
122}
123
124bool RE2::Set::Match(const StringPiece& text, std::vector<int>* v) const {
125 return Match(text, v, NULL);

Callers 4

mainFunction · 0.45
TESTFunction · 0.45
AddRegexpsAndCompileFunction · 0.45
TESTFunction · 0.45

Calls 11

sortClass · 0.85
ParseFlagsMethod · 0.80
max_memMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
shrink_to_fitMethod · 0.45
dataMethod · 0.45
resetMethod · 0.45
DecrefMethod · 0.45

Tested by 4

mainFunction · 0.36
TESTFunction · 0.36
AddRegexpsAndCompileFunction · 0.36
TESTFunction · 0.36