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

Unified Diff: third_party/re2/re2/regexp.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/regexp.h ('k') | third_party/re2/re2/set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/re2/regexp.cc
diff --git a/third_party/re2/re2/regexp.cc b/third_party/re2/re2/regexp.cc
index 99e72e50d55f350ace2ad9162365ac198e1b09a8..ed4c3a0616a0166f8600a35cf609ab8a06d9b450 100644
--- a/third_party/re2/re2/regexp.cc
+++ b/third_party/re2/re2/regexp.cc
@@ -14,7 +14,7 @@
// Constructor. Allocates vectors as appropriate for operator.
Regexp::Regexp(RegexpOp op, ParseFlags parse_flags)
- : op_(static_cast<uint8>(op)),
+ : op_(op),
simple_(false),
parse_flags_(static_cast<uint16>(parse_flags)),
ref_(1),
@@ -43,8 +43,7 @@
delete[] runes_;
break;
case kRegexpCharClass:
- if (cc_)
- cc_->Delete();
+ cc_->Delete();
delete ccb_;
break;
}
@@ -107,7 +106,7 @@
GLOBAL_MUTEX_LOCK(ref_mutex);
int r = (*ref_map)[this] - 1;
if (r < kMaxRef) {
- ref_ = static_cast<uint16>(r);
+ ref_ = r;
ref_map->erase(this);
} else {
(*ref_map)[this] = r;
@@ -212,13 +211,6 @@
if (nsub == 1)
return sub[0];
- if (nsub == 0) {
- if (op == kRegexpAlternate)
- return new Regexp(kRegexpNoMatch, flags);
- else
- return new Regexp(kRegexpEmptyMatch, flags);
- }
-
Regexp** subcopy = NULL;
if (op == kRegexpAlternate && can_factor) {
// Going to edit sub; make a copy so we don't step on caller.
@@ -453,11 +445,10 @@
continue;
}
- size_t n = stk.size();
+ int n = stk.size();
if (n == 0)
break;
- DCHECK_GE(n, 2);
a = stk[n-2];
b = stk[n-1];
stk.resize(n-2);
@@ -526,7 +517,7 @@
private:
int ncapture_;
- DISALLOW_COPY_AND_ASSIGN(NumCapturesWalker);
+ DISALLOW_EVIL_CONSTRUCTORS(NumCapturesWalker);
};
int Regexp::NumCaptures() {
@@ -570,7 +561,7 @@
private:
map<string, int>* map_;
- DISALLOW_COPY_AND_ASSIGN(NamedCapturesWalker);
+ DISALLOW_EVIL_CONSTRUCTORS(NamedCapturesWalker);
};
map<string, int>* Regexp::NamedCaptures() {
@@ -610,7 +601,7 @@
private:
map<int, string>* map_;
- DISALLOW_COPY_AND_ASSIGN(CaptureNamesWalker);
+ DISALLOW_EVIL_CONSTRUCTORS(CaptureNamesWalker);
};
map<int, string>* Regexp::CaptureNames() {
@@ -652,7 +643,7 @@
if (re->parse_flags() & Latin1) {
prefix->resize(re->nrunes_);
for (int j = 0; j < re->nrunes_; j++)
- (*prefix)[j] = static_cast<char>(re->runes_[j]);
+ (*prefix)[j] = re->runes_[j];
} else {
// Convert to UTF-8 in place.
// Assume worst-case space and then trim.
@@ -661,7 +652,7 @@
for (int j = 0; j < re->nrunes_; j++) {
Rune r = re->runes_[j];
if (r < Runeself)
- *p++ = static_cast<char>(r);
+ *p++ = r;
else
p += runetochar(p, &r);
}
@@ -671,14 +662,14 @@
case kRegexpLiteral:
if ((re->parse_flags() & Latin1) || re->rune_ < Runeself) {
- prefix->append(1, static_cast<char>(re->rune_));
+ prefix->append(1, re->rune_);
} else {
char buf[UTFmax];
prefix->append(buf, runetochar(buf, &re->rune_));
}
break;
}
- *foldcase = (sub[i]->parse_flags() & FoldCase) != 0;
+ *foldcase = (sub[i]->parse_flags() & FoldCase);
i++;
// The rest.
@@ -858,7 +849,7 @@
}
ranges_.clear();
- for (size_t i = 0; i < v.size(); i++)
+ for (int i = 0; i < v.size(); i++)
ranges_.insert(v[i]);
upper_ = AlphaMask & ~upper_;
@@ -924,12 +915,12 @@
}
CharClass* CharClassBuilder::GetCharClass() {
- CharClass* cc = CharClass::New(static_cast<int>(ranges_.size()));
+ CharClass* cc = CharClass::New(ranges_.size());
int n = 0;
for (iterator it = begin(); it != end(); ++it)
cc->ranges_[n++] = *it;
cc->nranges_ = n;
- DCHECK_LE(n, static_cast<int>(ranges_.size()));
+ DCHECK_LE(n, ranges_.size());
cc->nrunes_ = nrunes_;
cc->folds_ascii_ = FoldsASCII();
return cc;
« no previous file with comments | « third_party/re2/re2/regexp.h ('k') | third_party/re2/re2/set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698