From fc69fe1f2146733698548c63d558b33caa16ea68 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 6 Sep 2015 18:00:28 -0700 Subject: [PATCH] Use map.size and set.size in `mapToArray` and `setToArray`. --- lodash.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index e076f883a..94acc1b20 100644 --- a/lodash.js +++ b/lodash.js @@ -1148,9 +1148,11 @@ * @returns {Array} Returns the converted array. */ function mapToArray(map) { - var result = []; + var index = -1, + result = Array(map.size); + map.forEach(function(value, key) { - result.push([key, value]); + result[++index] = [key, value]; }); return result; } @@ -1187,9 +1189,11 @@ * @returns {Array} Returns the converted array. */ function setToArray(set) { - var result = []; + var index = -1, + result = Array(set.size); + set.forEach(function(value) { - result.push(value); + result[++index] = value; }); return result; }