From 98bcaaf27528d59bde723caf5dc93f8ee73438ad Mon Sep 17 00:00:00 2001 From: Alex Gorbatchev Date: Wed, 25 Jun 2014 15:55:08 -0700 Subject: [PATCH] Optimizes toArray for v8 --- lib/utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 976ca6c0..7764b45e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -11,7 +11,6 @@ define( function(debug) { 'use strict'; - var arry = []; var DEFAULT_INTERVAL = 100; function canWriteProtect() { @@ -35,7 +34,12 @@ define( }, toArray: function(obj, from) { - return arry.slice.call(obj, from); + from = from || 0; + var len = obj.length, arr = new Array(len - from); + for (var i = from; i < len; i++) { + arr[i - from] = obj[i]; + } + return arr; }, // returns new object representing multiple objects merged together