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
This commit is contained in:
sandholm@chromium.org 2011-01-07 13:21:34 +00:00
parent 90fd0ee897
commit ba4f9faec5
2 changed files with 3 additions and 2 deletions

View File

@ -121,6 +121,7 @@ function Join(array, length, separator, convert) {
if (IS_STRING(e)) return e;
return convert(e);
}
return '';
}
// Construct an array for the elements.
@ -160,7 +161,7 @@ function Join(array, length, separator, convert) {
function ConvertToString(x) {
if (IS_STRING(x)) return x;
// Assumes x is a non-string.
if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x));

View File

@ -1183,7 +1183,7 @@ function NewFunction(arg1) { // length == 1
if (n > 1) {
p = new $Array(n - 1);
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
// character - it may make the combined function expression
// compile. We avoid this problem by checking for this early on.