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); |
} |