summaryrefslogtreecommitdiffstats
path: root/src/array.js
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-12-15 09:54:21 +0000
committerSteve Block <steveblock@google.com>2009-12-15 09:54:21 +0000
commitd0582a6c46733687d045e4188a1bcd0123c758a1 (patch)
tree4139657adad206f69647f3d03f6fb2da2e8ae14e /src/array.js
parent3ce2e2076e8e3e60cf1810eec160ea2d8557e9e7 (diff)
downloadandroid_external_v8-d0582a6c46733687d045e4188a1bcd0123c758a1.tar.gz
android_external_v8-d0582a6c46733687d045e4188a1bcd0123c758a1.tar.bz2
android_external_v8-d0582a6c46733687d045e4188a1bcd0123c758a1.zip
Update V8 to r3431 as required by WebKit r51976.
Change-Id: I567392c3f8c0a0d5201a4249611ac4ccf468cd5b
Diffstat (limited to 'src/array.js')
-rw-r--r--src/array.js36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/array.js b/src/array.js
index 94d74a50..20d884ee 100644
--- a/src/array.js
+++ b/src/array.js
@@ -77,7 +77,8 @@ function SparseJoin(array, len, convert) {
var key = keys[i];
if (key != last_key) {
var e = array[key];
- builder.add(convert(e));
+ if (typeof(e) !== 'string') e = convert(e);
+ builder.add(e);
last_key = key;
}
}
@@ -114,17 +115,36 @@ function Join(array, length, separator, convert) {
if (length == 1) {
var e = array[0];
if (!IS_UNDEFINED(e) || (0 in array)) {
+ if (typeof(e) === 'string') return e;
return convert(e);
}
}
var builder = new StringBuilder();
- for (var i = 0; i < length; i++) {
- var e = array[i];
- if (i != 0) builder.add(separator);
- if (!IS_UNDEFINED(e) || (i in array)) {
- builder.add(convert(e));
+ // We pull the empty separator check outside the loop for speed!
+ if (separator.length == 0) {
+ for (var i = 0; i < length; i++) {
+ var e = array[i];
+ if (!IS_UNDEFINED(e) || (i in array)) {
+ if (typeof(e) !== 'string') e = convert(e);
+ if (e.length > 0) {
+ var elements = builder.elements;
+ elements[elements.length] = e;
+ }
+ }
+ }
+ } else {
+ for (var i = 0; i < length; i++) {
+ var e = array[i];
+ if (i != 0) builder.add(separator);
+ if (!IS_UNDEFINED(e) || (i in array)) {
+ if (typeof(e) !== 'string') e = convert(e);
+ if (e.length > 0) {
+ var elements = builder.elements;
+ elements[elements.length] = e;
+ }
+ }
}
}
return builder.generate();
@@ -136,12 +156,14 @@ function Join(array, length, separator, convert) {
function ConvertToString(e) {
+ if (typeof(e) === 'string') return e;
if (e == null) return '';
else return ToString(e);
}
function ConvertToLocaleString(e) {
+ if (typeof(e) === 'string') return e;
if (e == null) return '';
else {
// e_obj's toLocaleString might be overwritten, check if it is a function.
@@ -149,7 +171,7 @@ function ConvertToLocaleString(e) {
// See issue 877615.
var e_obj = ToObject(e);
if (IS_FUNCTION(e_obj.toLocaleString))
- return e_obj.toLocaleString();
+ return ToString(e_obj.toLocaleString());
else
return ToString(e);
}