Use map.size and set.size in mapToArray and setToArray.

This commit is contained in:
John-David Dalton
2015-09-06 18:00:28 -07:00
parent 38a16805ed
commit fc69fe1f21

View File

@@ -1148,9 +1148,11 @@
* @returns {Array} Returns the converted array. * @returns {Array} Returns the converted array.
*/ */
function mapToArray(map) { function mapToArray(map) {
var result = []; var index = -1,
result = Array(map.size);
map.forEach(function(value, key) { map.forEach(function(value, key) {
result.push([key, value]); result[++index] = [key, value];
}); });
return result; return result;
} }
@@ -1187,9 +1189,11 @@
* @returns {Array} Returns the converted array. * @returns {Array} Returns the converted array.
*/ */
function setToArray(set) { function setToArray(set) {
var result = []; var index = -1,
result = Array(set.size);
set.forEach(function(value) { set.forEach(function(value) {
result.push(value); result[++index] = value;
}); });
return result; return result;
} }