Bug 1382023 - Fold repeated assertions. r=jandem
authorSean Stangl <sstangl@mozilla.com>
Tue, 18 Jul 2017 15:37:00 -0400
changeset 418707 fef3121e0dd2874b6dec7e7073ceabef634ead23
parent 418706 6005f81525769a952b8005d5494e619d2d69efb4
child 418708 762b5a6fe6692567fbd4fbf610474d2fa9f7657e
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1382023
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382023 - Fold repeated assertions. r=jandem This is a pull of v8 commit c8e4c8b9263b5009716804f06f39225a9dd7fc68, reviewed at https://codereview.chromium.org/2768443003.
js/src/irregexp/RegExpParser.cpp
--- a/js/src/irregexp/RegExpParser.cpp
+++ b/js/src/irregexp/RegExpParser.cpp
@@ -124,16 +124,22 @@ RegExpBuilder::AddAtom(RegExpTree* term)
     last_added_ = ADD_ATOM;
 #endif
 }
 
 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(alloc, assert);
 #ifdef DEBUG
     last_added_ = ADD_ASSERT;
 #endif
 }
 
 void
 RegExpBuilder::NewAlternative()