Revision: 15223
Author: [email protected]
Date: Thu Jun 20 01:13:21 2013
Log: Directly use C++ builtin of ArrayPush for String.prototype.split.
[email protected]
BUG=v8:2737
Review URL: https://codereview.chromium.org/17283007
http://code.google.com/p/v8/source/detail?r=15223
Modified:
/branches/bleeding_edge/src/string.js
=======================================
--- /branches/bleeding_edge/src/string.js Wed Jun 19 05:25:40 2013
+++ /branches/bleeding_edge/src/string.js Thu Jun 20 01:13:21 2013
@@ -644,6 +644,8 @@
}
+var ArrayPushBuiltin = $Array.prototype.push;
+
function StringSplitOnRegExp(subject, separator, limit, length) {
%_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
@@ -657,19 +659,21 @@
var currentIndex = 0;
var startIndex = 0;
var startMatch = 0;
- var result = new InternalArray();
+ var result = [];
outer_loop:
while (true) {
if (startIndex === length) {
- result.push(%_SubString(subject, currentIndex, length));
+ %_CallFunction(result, %_SubString(subject, currentIndex, length),
+ ArrayPushBuiltin);
break;
}
var matchInfo = DoRegExpExec(separator, subject, startIndex);
if (matchInfo == null || length === (startMatch =
matchInfo[CAPTURE0])) {
- result.push(%_SubString(subject, currentIndex, length));
+ %_CallFunction(result, %_SubString(subject, currentIndex, length),
+ ArrayPushBuiltin);
break;
}
var endIndex = matchInfo[CAPTURE1];
@@ -680,7 +684,8 @@
continue;
}
- result.push(%_SubString(subject, currentIndex, startMatch));
+ %_CallFunction(result, %_SubString(subject, currentIndex, startMatch),
+ ArrayPushBuiltin);
if (result.length === limit) break;
@@ -689,16 +694,17 @@
var start = matchInfo[i++];
var end = matchInfo[i++];
if (end != -1) {
- result.push(%_SubString(subject, start, end));
+ %_CallFunction(result, %_SubString(subject, start, end),
+ ArrayPushBuiltin);
} else {
- result.push(void 0);
+ %_CallFunction(result, void 0, ArrayPushBuiltin);
}
if (result.length === limit) break outer_loop;
}
startIndex = currentIndex = endIndex;
}
- return %MoveArrayContents(result, []);
+ return result;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.