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

Unified Diff: src/string.js

Issue 281953002: Fix performance regression in regular expressions after Array.push() optimizations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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
« src/regexp.js ('K') | « src/regexp.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 9c90427835342acff919b9725e05c159c13b548b..d4d679b175369d083ab33aafa7eeffe6f0eebce9 100644
--- a/src/string.js
+++ b/src/string.js
@@ -618,8 +618,6 @@ function StringSplit(separator, limit) {
}
-var ArrayPushBuiltin = $Array.prototype.push;
-
function StringSplitOnRegExp(subject, separator, limit, length) {
if (length === 0) {
if (DoRegExpExec(separator, subject, 0, 0) != null) {
@@ -637,15 +635,13 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
while (true) {
if (startIndex === length) {
- %_CallFunction(result, %_SubString(subject, currentIndex, length),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, currentIndex, length);
break;
}
var matchInfo = DoRegExpExec(separator, subject, startIndex);
if (matchInfo == null || length === (startMatch = matchInfo[CAPTURE0])) {
- %_CallFunction(result, %_SubString(subject, currentIndex, length),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, currentIndex, length);
break;
}
var endIndex = matchInfo[CAPTURE1];
@@ -656,8 +652,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
continue;
}
- %_CallFunction(result, %_SubString(subject, currentIndex, startMatch),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, currentIndex, startMatch);
if (result.length === limit) break;
@@ -666,10 +661,9 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
var start = matchInfo[i++];
var end = matchInfo[i++];
if (end != -1) {
- %_CallFunction(result, %_SubString(subject, start, end),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, start, end);
} else {
- %_CallFunction(result, UNDEFINED, ArrayPushBuiltin);
+ result[result.length] = UNDEFINED;
}
if (result.length === limit) break outer_loop;
}
« src/regexp.js ('K') | « src/regexp.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698