Backed out changeset 817e8aab2348 (bug 887016)
authorTooru Fujisawa <arai_a@mac.com>
Mon, 28 Mar 2016 06:49:53 +0900
changeset 290646 9cb8165a2a66701fc5550b19ba29b3fa3ffd4714
parent 290645 7596439fda73345a5eecddb205c2508967a8eaa7
child 290647 d44ccce05064d63cd96efd511694bc1a28d94646
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs887016
milestone48.0a1
backs out817e8aab2348ecd7a16df359e054ef8fb14491de
Backed out changeset 817e8aab2348 (bug 887016)
js/src/builtin/RegExp.js
--- a/js/src/builtin/RegExp.js
+++ b/js/src/builtin/RegExp.js
@@ -182,21 +182,18 @@ function RegExpReplace(string, replaceVa
         firstDollarIndex = callFunction(std_String_indexOf, replaceValue, "$");
     }
 
     // Step 7.
     var global = !!rx.global;
 
     // Optimized paths for simple cases.
     if (!functionalReplace && firstDollarIndex === -1 && IsRegExpReplaceOptimizable(rx)) {
-        if (global) {
-            if (lengthS < 0x7fff)
-                return RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue);
+        if (global)
             return RegExpGlobalReplaceOpt(rx, S, lengthS, replaceValue);
-        }
         return RegExpLocalReplaceOpt(rx, S, lengthS, replaceValue);
     }
 
     // Step 8.
     var fullUnicode = false;
     if (global) {
         // Step 8.a.
         fullUnicode = !!rx.unicode;
@@ -345,71 +342,16 @@ function RegExpReplace(string, replaceVa
     // Step 15.
     if (nextSourcePosition >= lengthS)
         return accumulatedResult;
 
     // Step 16.
     return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
 }
 
-// ES 2016 draft Mar 25, 2016 21.2.5.8 steps 8.a-16.
-// Optimized path for @@replace with global flag, short string.
-function RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue)
-{
-   // Step 8.a.
-    var fullUnicode = !!rx.unicode;
-
-    // Step 8.b.
-    var lastIndex = 0;
-    rx.lastIndex = 0;
-
-    // Step 12 (reordered).
-    var accumulatedResult = "";
-
-    // Step 13 (reordered).
-    var nextSourcePosition = 0;
-
-    var sticky = !!rx.sticky;
-
-    // Step 11.
-    while (true) {
-        // Step 11.a.
-        var result = RegExpSearcher(rx, S, lastIndex, sticky);
-
-        // Step 11.b.
-        if (result === -1)
-            break;
-
-        var position = result & 0x7fff;
-        lastIndex = (result >> 15) & 0x7fff;
-
-        // Step 14.l.ii.
-        accumulatedResult += Substring(S, nextSourcePosition,
-                                       position - nextSourcePosition) + replaceValue;
-
-        // Step 14.l.iii.
-        nextSourcePosition = lastIndex;
-
-        // Step 11.c.iii.2.
-        if (lastIndex === position) {
-            lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
-            if (lastIndex > lengthS)
-                break;
-        }
-    }
-
-    // Step 15.
-    if (nextSourcePosition >= lengthS)
-        return accumulatedResult;
-
-    // Step 16.
-    return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
-}
-
-// ES 2016 draft Mar 25, 2016 21.2.5.8 steps 8.a-16.
 // Optimized path for @@replace with global flag.
 function RegExpGlobalReplaceOpt(rx, S, lengthS, replaceValue)
 {
    // Step 8.a.
     var fullUnicode = !!rx.unicode;
 
     // Step 8.b.
     var lastIndex = 0;
@@ -463,17 +405,16 @@ function RegExpGlobalReplaceOpt(rx, S, l
     // Step 15.
     if (nextSourcePosition >= lengthS)
         return accumulatedResult;
 
     // Step 16.
     return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
 }
 
-// ES 2016 draft Mar 25, 2016 21.2.5.8 steps 11.a-16.
 // Optimized path for @@replace without global flag.
 function RegExpLocalReplaceOpt(rx, S, lengthS, replaceValue)
 {
     var sticky = !!rx.sticky;
 
     var lastIndex = sticky ? rx.lastIndex : 0;
 
     // Step 11.a.