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

Unified Diff: src/regexp/regexp-parser.cc

Issue 2768443003: [regexp] Fold repeated assertions (Closed)
Patch Set: Simpler solution during parsing Created 3 years, 9 months 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 | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-parser.cc
diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc
index 1d7829a4b77d830e78d665149267055fa20f4928..33a16ef01fb2637c402d84a677c9feb3662f8fe3 100644
--- a/src/regexp/regexp-parser.cc
+++ b/src/regexp/regexp-parser.cc
@@ -1691,6 +1691,12 @@ void RegExpBuilder::AddTerm(RegExpTree* term) {
void RegExpBuilder::AddAssertion(RegExpTree* assert) {
FlushText();
+ if (terms_.length() > 0 && terms_.last()->IsAssertion()) {
+ // Omit repeated assertions of the same type.
+ RegExpAssertion* last = terms_.last()->AsAssertion();
+ RegExpAssertion* next = assert->AsAssertion();
+ if (last->assertion_type() == next->assertion_type()) return;
+ }
terms_.Add(assert, zone());
LAST(ADD_ASSERT);
}
« no previous file with comments | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698