Reviewers: erik.corry,

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

Please review this at http://codereview.chromium.org/1888

Affected files:
   M     src/array.js


Index: src/array.js
===================================================================
--- src/array.js        (revision 230)
+++ src/array.js        (working copy)
@@ -111,6 +111,14 @@
        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++) {



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to