Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: third_party/re2/re2/compile.cc

Issue 1530113002: Revert of Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/re2/re2/bitstate.cc ('k') | third_party/re2/re2/dfa.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/re2/compile.cc
diff --git a/third_party/re2/re2/compile.cc b/third_party/re2/re2/compile.cc
index 50375242e5e26f8acbfb109efd244e3bdc930999..9a59f1354473edbbafe58ea7f437b921ff815383 100644
--- a/third_party/re2/re2/compile.cc
+++ b/third_party/re2/re2/compile.cc
@@ -230,7 +230,7 @@
RE2::Anchor anchor_; // anchor mode for RE2::Set
- DISALLOW_COPY_AND_ASSIGN(Compiler);
+ DISALLOW_EVIL_CONSTRUCTORS(Compiler);
};
Compiler::Compiler() {
@@ -371,8 +371,6 @@
// Given a fragment for a, returns a fragment for a? or a?? (if nongreedy)
Frag Compiler::Quest(Frag a, bool nongreedy) {
- if (IsNoMatch(a))
- return Nop();
int id = AllocInst(1);
if (id < 0)
return NoMatch();
@@ -435,10 +433,7 @@
if (empty & (kEmptyWordBoundary|kEmptyNonWordBoundary)) {
int j;
for (int i = 0; i < 256; i = j) {
- for (j = i + 1; j < 256 &&
- Prog::IsWordChar(static_cast<uint8>(i)) ==
- Prog::IsWordChar(static_cast<uint8>(j));
- j++)
+ for (j = i+1; j < 256 && Prog::IsWordChar(i) == Prog::IsWordChar(j); j++)
;
prog_->MarkByteRange(i, j-1);
}
@@ -448,8 +443,6 @@
// Given a fragment a, returns a fragment with capturing parens around a.
Frag Compiler::Capture(Frag a, int n) {
- if (IsNoMatch(a))
- return NoMatch();
int id = AllocInst(2);
if (id < 0)
return NoMatch();
@@ -506,10 +499,7 @@
return UncachedRuneByteSuffix(lo, hi, foldcase, next);
}
- uint64 key = (uint64)next << 17 |
- (uint64)lo << 9 |
- (uint64)hi << 1 |
- (uint64)foldcase;
+ uint64 key = ((uint64)next << 17) | (lo<<9) | (hi<<1) | (foldcase ? 1ULL : 0ULL);
map<uint64, int>::iterator it = rune_cache_.find(key);
if (it != rune_cache_.end())
return it->second;
@@ -561,8 +551,7 @@
return;
if (hi > 0xFF)
hi = 0xFF;
- AddSuffix(RuneByteSuffix(static_cast<uint8>(lo), static_cast<uint8>(hi),
- foldcase, 0));
+ AddSuffix(RuneByteSuffix(lo, hi, foldcase, 0));
}
// Table describing how to make a UTF-8 matching machine
@@ -603,8 +592,7 @@
int next = 0;
if (p.next >= 0)
next = inst[p.next];
- inst[i] = UncachedRuneByteSuffix(static_cast<uint8>(p.lo),
- static_cast<uint8>(p.hi), false, next);
+ inst[i] = UncachedRuneByteSuffix(p.lo, p.hi, false, next);
if ((p.lo & 0xC0) != 0x80)
AddSuffix(inst[i]);
}
@@ -633,8 +621,7 @@
// ASCII range is always a special case.
if (hi < Runeself) {
- AddSuffix(RuneByteSuffix(static_cast<uint8>(lo), static_cast<uint8>(hi),
- foldcase, 0));
+ AddSuffix(RuneByteSuffix(lo, hi, foldcase, 0));
return;
}
@@ -762,16 +749,16 @@
}
case kRegexpStar:
- return Star(child_frags[0], (re->parse_flags()&Regexp::NonGreedy) != 0);
+ return Star(child_frags[0], re->parse_flags()&Regexp::NonGreedy);
case kRegexpPlus:
- return Plus(child_frags[0], (re->parse_flags()&Regexp::NonGreedy) != 0);
+ return Plus(child_frags[0], re->parse_flags()&Regexp::NonGreedy);
case kRegexpQuest:
- return Quest(child_frags[0], (re->parse_flags()&Regexp::NonGreedy) != 0);
+ return Quest(child_frags[0], re->parse_flags()&Regexp::NonGreedy);
case kRegexpLiteral:
- return Literal(re->rune(), (re->parse_flags()&Regexp::FoldCase) != 0);
+ return Literal(re->rune(), re->parse_flags()&Regexp::FoldCase);
case kRegexpLiteralString: {
// Concatenation of literals.
@@ -779,8 +766,7 @@
return Nop();
Frag f;
for (int i = 0; i < re->nrunes(); i++) {
- Frag f1 = Literal(re->runes()[i],
- (re->parse_flags()&Regexp::FoldCase) != 0);
+ Frag f1 = Literal(re->runes()[i], re->parse_flags()&Regexp::FoldCase);
if (i == 0)
f = f1;
else
@@ -825,8 +811,7 @@
// If this range contains all of A-Za-z or none of it,
// the fold flag is unnecessary; don't bother.
bool fold = foldascii;
- if ((i->lo <= 'A' && 'z' <= i->hi) || i->hi < 'A' || 'z' < i->lo ||
- ('Z' < i->lo && i->hi < 'a'))
+ if ((i->lo <= 'A' && 'z' <= i->hi) || i->hi < 'A' || 'z' < i->lo)
fold = false;
AddRuneRange(i->lo, i->hi, fold);
@@ -969,7 +954,7 @@
max_mem_ = max_mem;
if (max_mem <= 0) {
max_inst_ = 100000; // more than enough
- } else if (max_mem <= static_cast<int64>(sizeof(Prog))) {
+ } else if (max_mem <= sizeof(Prog)) {
// No room for anything.
max_inst_ = 0;
} else {
@@ -989,7 +974,7 @@
if (m > Prog::Inst::kMaxInst)
m = Prog::Inst::kMaxInst;
- max_inst_ = static_cast<int>(m);
+ max_inst_ = m;
}
anchor_ = anchor;
« no previous file with comments | « third_party/re2/re2/bitstate.cc ('k') | third_party/re2/re2/dfa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698