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

Unified Diff: src/js/array.js

Issue 2141603002: Make toLocaleString on arrays always call toLocaleString on its elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Simplify. Created 4 years, 5 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 | test/mjsunit/array-tostring.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/array.js
diff --git a/src/js/array.js b/src/js/array.js
index c29b8f7256ad1d2c568f5a5103d4c666f4aaf485..2fde9fb3d4b3ae3f4d9f3abc849537c7f63fb339 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -151,8 +151,7 @@ function DoJoin(array, length, is_array, separator, convert) {
// Fast case for one-element arrays.
if (length === 1) {
- var e = array[0];
- return IS_STRING(e) ? e : convert(e);
+ return convert(array[0]);
}
// Construct an array for the elements.
@@ -161,31 +160,14 @@ function DoJoin(array, length, is_array, separator, convert) {
// We pull the empty separator check outside the loop for speed!
if (separator === '') {
for (var i = 0; i < length; i++) {
- var e = array[i];
- elements[i] = IS_STRING(e) ? e : convert(e);
+ elements[i] = convert(array[i]);
}
return %StringBuilderConcat(elements, length, '');
}
// Non-empty separator case.
- // If the first element is a number then use the heuristic that the
- // remaining elements are also likely to be numbers.
- var e = array[0];
- if (IS_NUMBER(e)) {
- elements[0] = %_NumberToString(e);
- for (var i = 1; i < length; i++) {
- e = array[i];
- if (IS_NUMBER(e)) {
- elements[i] = %_NumberToString(e);
- } else {
- elements[i] = IS_STRING(e) ? e : convert(e);
- }
- }
- } else {
- elements[0] = IS_STRING(e) ? e : convert(e);
- for (var i = 1; i < length; i++) {
- e = array[i];
- elements[i] = IS_STRING(e) ? e : convert(e);
- }
+ elements[0] = convert(array[0]);
+ for (var i = 1; i < length; i++) {
+ elements[i] = convert(array[i]);
}
return %StringBuilderJoin(elements, length, separator);
}
« no previous file with comments | « no previous file | test/mjsunit/array-tostring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698