From aa8eb8747c4755924c1b5620a5c45a7fbc72a9d1 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 16 Jan 2017 16:56:48 +0800 Subject: [PATCH] http: use direct parameters instead When parameter count is fixed, use literal Array instance is more simply and avoid arguments leak also. PR-URL: https://github.com/nodejs/node/pull/10833 Reviewed-By: Luigi Pinca Reviewed-By: Brian White --- lib/_http_client.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index 840a6a2f0997de..e8285fe81012c7 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -718,21 +718,15 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) { return this; }; -ClientRequest.prototype.setNoDelay = function setNoDelay() { - const argsLen = arguments.length; - const args = new Array(argsLen); - for (var i = 0; i < argsLen; i++) - args[i] = arguments[i]; - this._deferToConnect('setNoDelay', args); -}; -ClientRequest.prototype.setSocketKeepAlive = function setSocketKeepAlive() { - const argsLen = arguments.length; - const args = new Array(argsLen); - for (var i = 0; i < argsLen; i++) - args[i] = arguments[i]; - this._deferToConnect('setKeepAlive', args); +ClientRequest.prototype.setNoDelay = function setNoDelay(noDelay) { + this._deferToConnect('setNoDelay', [noDelay]); }; +ClientRequest.prototype.setSocketKeepAlive = + function setSocketKeepAlive(enable, initialDelay) { + this._deferToConnect('setKeepAlive', [enable, initialDelay]); + }; + ClientRequest.prototype.clearTimeout = function clearTimeout(cb) { this.setTimeout(0, cb); };