Chromium Code Reviews| Index: third_party/re2/re2/compile.cc |
| diff --git a/third_party/re2/re2/compile.cc b/third_party/re2/re2/compile.cc |
| index 14e401afc55a547acf9d799702c33bde8fc25630..08cb6fa8f0417f5ac799d3c24a822e423460cced 100644 |
| --- a/third_party/re2/re2/compile.cc |
| +++ b/third_party/re2/re2/compile.cc |
| @@ -110,10 +110,6 @@ struct Frag { |
| Frag(uint32 begin, PatchList end) : begin(begin), end(end) {} |
| }; |
| -static Frag NullFrag() { |
| - return Frag(); |
| -} |
| - |
| // Input encodings. |
| enum Encoding { |
| kEncodingUTF8 = 1, // UTF-8 (0-10FFFF) |
| @@ -375,6 +371,8 @@ Frag Compiler::Plus(Frag a, bool nongreedy) { |
| // Given a fragment for a, returns a fragment for a? or a?? (if nongreedy) |
| Frag Compiler::Quest(Frag a, bool nongreedy) { |
| + if (IsNoMatch(a)) |
|
Nico
2015/04/22 22:17:03
this isn't from https://github.com/google/re2/comm
|
| + return Nop(); |
| int id = AllocInst(1); |
| if (id < 0) |
| return NoMatch(); |
| @@ -447,6 +445,8 @@ Frag Compiler::EmptyWidth(EmptyOp empty) { |
| // Given a fragment a, returns a fragment with capturing parens around a. |
| Frag Compiler::Capture(Frag a, int n) { |
| + if (IsNoMatch(a)) |
|
Nico
2015/04/22 22:17:03
this isn't from https://github.com/google/re2/comm
|
| + return NoMatch(); |
| int id = AllocInst(2); |
| if (id < 0) |
| return NoMatch(); |
| @@ -503,7 +503,7 @@ int Compiler::RuneByteSuffix(uint8 lo, uint8 hi, bool foldcase, int next) { |
| return UncachedRuneByteSuffix(lo, hi, foldcase, next); |
| } |
| - uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | (foldcase ? 1ULL : 0ULL); |
| + uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | foldcase; |
|
Nico
2015/04/22 22:17:03
this isn't from https://github.com/google/re2/comm
|
| map<uint64, int>::iterator it = rune_cache_.find(key); |
| if (it != rune_cache_.end()) |
| return it->second; |
| @@ -685,13 +685,13 @@ Frag Compiler::PreVisit(Regexp* re, Frag, bool* stop) { |
| if (failed_) |
| *stop = true; |
| - return NullFrag(); // not used by caller |
| + return Frag(); // not used by caller |
| } |
| Frag Compiler::Literal(Rune r, bool foldcase) { |
| switch (encoding_) { |
| default: |
| - return NullFrag(); |
| + return Frag(); |
| case kEncodingLatin1: |
| return ByteRange(r, r, foldcase); |
| @@ -1007,7 +1007,7 @@ Prog* Compiler::Compile(Regexp* re, bool reversed, int64 max_mem) { |
| bool is_anchor_end = IsAnchorEnd(&sre, 0); |
| // Generate fragment for entire regexp. |
| - Frag f = c.WalkExponential(sre, NullFrag(), 2*c.max_inst_); |
| + Frag f = c.WalkExponential(sre, Frag(), 2*c.max_inst_); |
| sre->Decref(); |
| if (c.failed_) |
| return NULL; |
| @@ -1098,7 +1098,7 @@ Prog* Compiler::CompileSet(const RE2::Options& options, RE2::Anchor anchor, |
| c.Setup(pf, options.max_mem(), anchor); |
| // Compile alternation of fragments. |
| - Frag all = c.WalkExponential(re, NullFrag(), 2*c.max_inst_); |
| + Frag all = c.WalkExponential(re, Frag(), 2*c.max_inst_); |
| re->Decref(); |
| if (c.failed_) |
| return NULL; |