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

Unified Diff: src/array.js

Issue 607503004: Add a fast case for one-element arrays in ArrayJoin (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove cases handled properly by NonStringToString Created 6 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
diff --git a/src/array.js b/src/array.js
index 44deff7de42c60986741615b1be389f9668dbf85..bef757830919c3f88b92d1e58ba2af8d1d8edd93 100644
--- a/src/array.js
+++ b/src/array.js
@@ -378,6 +378,14 @@ function ArrayJoin(separator) {
var result = %_FastOneByteArrayJoin(array, separator);
if (!IS_UNDEFINED(result)) return result;
+ // Fast case for one-element arrays.
+ if (length === 1) {
+ var e = array[0];
+ if (IS_STRING(e)) return e;
+ if (IS_NULL_OR_UNDEFINED(e)) return '';
+ return NonStringToString(e);
+ }
+
return Join(array, length, separator, ConvertToString);
}
« 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