Commit ba4f9fae authored by sandholm@chromium.org's avatar sandholm@chromium.org

Aviod double checking IS_STRING when joining arrays.

Review URL: http://codereview.chromium.org/5977013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6226 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 90fd0ee8
...@@ -121,6 +121,7 @@ function Join(array, length, separator, convert) { ...@@ -121,6 +121,7 @@ function Join(array, length, separator, convert) {
if (IS_STRING(e)) return e; if (IS_STRING(e)) return e;
return convert(e); return convert(e);
} }
return '';
} }
// Construct an array for the elements. // Construct an array for the elements.
...@@ -160,7 +161,7 @@ function Join(array, length, separator, convert) { ...@@ -160,7 +161,7 @@ function Join(array, length, separator, convert) {
function ConvertToString(x) { function ConvertToString(x) {
if (IS_STRING(x)) return x; // Assumes x is a non-string.
if (IS_NUMBER(x)) return %_NumberToString(x); if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x)); return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x));
......
...@@ -1183,7 +1183,7 @@ function NewFunction(arg1) { // length == 1 ...@@ -1183,7 +1183,7 @@ function NewFunction(arg1) { // length == 1
if (n > 1) { if (n > 1) {
p = new $Array(n - 1); p = new $Array(n - 1);
for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i); for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i);
p = Join(p, n - 1, ',', ToString); p = Join(p, n - 1, ',', NonStringToString);
// If the formal parameters string include ) - an illegal // If the formal parameters string include ) - an illegal
// character - it may make the combined function expression // character - it may make the combined function expression
// compile. We avoid this problem by checking for this early on. // compile. We avoid this problem by checking for this early on.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment