Commit e7fbf99b authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Optimize concat for one argument (two if you count 'this').

Review URL: http://codereview.chromium.org/584006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3815 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 862909e7
......@@ -87,14 +87,18 @@ function StringCharCodeAt(pos) {
// ECMA-262, section 15.5.4.6
function StringConcat() {
var len = %_ArgumentsLength() + 1;
var parts = new $Array(len);
parts[0] = IS_STRING(this) ? this : ToString(this);
for (var i = 1; i < len; i++) {
var part = %_Arguments(i - 1);
parts[i] = IS_STRING(part) ? part : ToString(part);
var len = %_ArgumentsLength();
var this_as_string = IS_STRING(this) ? this : ToString(this);
if (len === 1) {
return this_as_string + %_Arguments(0);
}
return %StringBuilderConcat(parts, len, "");
var parts = new $Array(len + 1);
parts[0] = this_as_string;
for (var i = 0; i < len; i++) {
var part = %_Arguments(i);
parts[i + 1] = IS_STRING(part) ? part : ToString(part);
}
return %StringBuilderConcat(parts, len + 1, "");
}
// Match ES3 and Safari
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment