Skip to content

Commit 75b63b2

Browse files
committed
http: use direct parameters instead
When parameter count is fixed, use literal Array instance is more simply and avoid arguments leak also.
1 parent 98bb65f commit 75b63b2

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
@@ -714,21 +714,15 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) {
714714
return this;
715715
};
716716

717-
ClientRequest.prototype.setNoDelay = function setNoDelay() {
718-
const argsLen = arguments.length;
719-
const args = new Array(argsLen);
720-
for (var i = 0; i < argsLen; i++)
721-
args[i] = arguments[i];
722-
this._deferToConnect('setNoDelay', args);
723-
};
724-
ClientRequest.prototype.setSocketKeepAlive = function setSocketKeepAlive() {
725-
const argsLen = arguments.length;
726-
const args = new Array(argsLen);
727-
for (var i = 0; i < argsLen; i++)
728-
args[i] = arguments[i];
729-
this._deferToConnect('setKeepAlive', args);
717+
ClientRequest.prototype.setNoDelay = function setNoDelay(noDelay) {
718+
this._deferToConnect('setNoDelay', [noDelay]);
730719
};
731720

721+
ClientRequest.prototype.setSocketKeepAlive =
722+
function setSocketKeepAlive(enable, initialDelay) {
723+
this._deferToConnect('setKeepAlive', [enable, initialDelay]);
724+
};
725+
732726
ClientRequest.prototype.clearTimeout = function clearTimeout(cb) {
733727
this.setTimeout(0, cb);
734728
};

0 commit comments

Comments
 (0)