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

Unified Diff: src/string.js

Issue 17391016: Avoid relying on monkey-patchable things in String.prototype.split. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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/mjsunit/regress/string-split-monkey-patching.js » ('j') | 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 a04b23f7dbb0e54e1b9df385d275a27465e2220d..87b6dafb42d7cc1ce0454918daba97b6f2c6dc76 100644
--- a/src/string.js
+++ b/src/string.js
@@ -663,13 +663,13 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
while (true) {
if (startIndex === length) {
- result.push(%_SubString(subject, currentIndex, length));
+ result[result.length] = %_SubString(subject, currentIndex, length);
Yang 2013/06/19 10:30:43 Wouldn't it be possible to install an indexed gett
break;
}
var matchInfo = DoRegExpExec(separator, subject, startIndex);
if (matchInfo == null || length === (startMatch = matchInfo[CAPTURE0])) {
- result.push(%_SubString(subject, currentIndex, length));
+ result[result.length] = %_SubString(subject, currentIndex, length);
break;
}
var endIndex = matchInfo[CAPTURE1];
@@ -680,7 +680,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
continue;
}
- result.push(%_SubString(subject, currentIndex, startMatch));
+ result[result.length] = %_SubString(subject, currentIndex, startMatch);
if (result.length === limit) break;
@@ -689,9 +689,9 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
var start = matchInfo[i++];
var end = matchInfo[i++];
if (end != -1) {
- result.push(%_SubString(subject, start, end));
+ result[result.length] = %_SubString(subject, start, end);
} else {
- result.push(void 0);
+ result[result.length] = void 0;
}
if (result.length === limit) break outer_loop;
}
« no previous file with comments | « no previous file | test/mjsunit/regress/string-split-monkey-patching.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698