From c0a2e02f51e3b625ce0356b07b3ab53df8693254 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 26 Feb 2017 18:08:04 -0800 Subject: [PATCH] net: avoid using forEach PR-URL: https://github.com/nodejs/node/pull/11582 Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig --- lib/net.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/net.js b/lib/net.js index 3c009a00fb77c0..309f38c360736b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1502,9 +1502,9 @@ Server.prototype.getConnections = function(cb) { if (--left === 0) return end(null, total); } - this._slaves.forEach(function(slave) { - slave.getConnections(oncount); - }); + for (var n = 0; n < this._slaves.length; n++) { + this._slaves[n].getConnections(oncount); + } }; @@ -1540,9 +1540,8 @@ Server.prototype.close = function(cb) { this._connections++; // Poll slaves - this._slaves.forEach(function(slave) { - slave.close(onSlaveClose); - }); + for (var n = 0; n < this._slaves.length; n++) + this._slaves[n].close(onSlaveClose); } else { this._emitCloseIfDrained(); }