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

Unified Diff: src/array.js

Issue 1888: Avoid the creation of a string builder for joining one-element arrays. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
===================================================================
--- src/array.js (revision 230)
+++ src/array.js (working copy)
@@ -111,6 +111,14 @@
return SparseJoin(array, length, convert);
}
+ // Fast case for one-element arrays.
+ if (length === 1) {
+ var e = array[0];
+ if (!IS_UNDEFINED(e) || (0 in array)) {
+ return convert(e);
+ }
+ }
+
var builder = new StringBuilder();
for (var i = 0; i < length; i++) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698