Commit 1aa48bb9 authored by ager@chromium.org's avatar ager@chromium.org

Avoid the creation of a string builder for joining one-element arrays.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@250 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0157bcd8
......@@ -111,6 +111,14 @@ function Join(array, length, separator, convert) {
return SparseJoin(array, length, convert);
}
// Fast case for one-element arrays.
if (length == 1) {
var e = array[0];
if (!IS_UNDEFINED(e) || (0 in array)) {
return convert(e);
}
}
var builder = new StringBuilder();
for (var i = 0; i < length; i++) {
......
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