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

Unified Diff: src/string.js

Issue 521054: Improve the performance of String.prototype.concat and the slow-case... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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 | « src/runtime.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
===================================================================
--- src/string.js (revision 3550)
+++ src/string.js (working copy)
@@ -87,12 +87,14 @@
// ECMA-262, section 15.5.4.6
function StringConcat() {
- var len = %_ArgumentsLength();
- var parts = new $Array(len + 1);
- parts[0] = ToString(this);
- for (var i = 0; i < len; i++)
- parts[i + 1] = ToString(%_Arguments(i));
- return parts.join('');
+ 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);
+ }
+ return %StringBuilderConcat(parts, len, "");
}
// Match ES3 and Safari
« no previous file with comments | « src/runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698