From bcdf7e94beb10635619c611ff72d70023acecbed Mon Sep 17 00:00:00 2001 From: himself65 Date: Mon, 25 May 2020 18:36:33 +0800 Subject: [PATCH] http: simplify Agent initialization PR-URL: https://github.com/nodejs/node/pull/33551 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Denys Otrishko Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Robert Nagy --- lib/_http_agent.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 906625d0a499ec..91ca52c4e6e52f 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -125,8 +125,8 @@ function Agent(options) { return; } - let freeSockets = this.freeSockets[name]; - const freeLen = freeSockets ? freeSockets.length : 0; + const freeSockets = this.freeSockets[name] || []; + const freeLen = freeSockets.length; let count = freeLen; if (this.sockets[name]) count += this.sockets[name].length; @@ -138,7 +138,6 @@ function Agent(options) { return; } - freeSockets = freeSockets || []; this.freeSockets[name] = freeSockets; socket[async_id_symbol] = -1; socket._httpMessage = null;