Skip to content

Commit aa8eb87

Browse files
JacksonTianItalo A. Casas
authored andcommitted
http: use direct parameters instead
When parameter count is fixed, use literal Array instance is more simply and avoid arguments leak also. PR-URL: #10833 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 90c2ac7 commit aa8eb87

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

lib/_http_client.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -718,21 +718,15 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) {
718718
return this;
719719
};
720720

721-
ClientRequest.prototype.setNoDelay = function setNoDelay() {
722-
const argsLen = arguments.length;
723-
const args = new Array(argsLen);
724-
for (var i = 0; i < argsLen; i++)
725-
args[i] = arguments[i];
726-
this._deferToConnect('setNoDelay', args);
727-
};
728-
ClientRequest.prototype.setSocketKeepAlive = function setSocketKeepAlive() {
729-
const argsLen = arguments.length;
730-
const args = new Array(argsLen);
731-
for (var i = 0; i < argsLen; i++)
732-
args[i] = arguments[i];
733-
this._deferToConnect('setKeepAlive', args);
721+
ClientRequest.prototype.setNoDelay = function setNoDelay(noDelay) {
722+
this._deferToConnect('setNoDelay', [noDelay]);
734723
};
735724

725+
ClientRequest.prototype.setSocketKeepAlive =
726+
function setSocketKeepAlive(enable, initialDelay) {
727+
this._deferToConnect('setKeepAlive', [enable, initialDelay]);
728+
};
729+
736730
ClientRequest.prototype.clearTimeout = function clearTimeout(cb) {
737731
this.setTimeout(0, cb);
738732
};

0 commit comments

Comments
 (0)