Skip to content

Commit 4c0f297

Browse files
JacksonTianevanlucas
authored andcommittedJan 31, 2017
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 <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent 438a98c commit 4c0f297

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed
 

‎lib/_http_client.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -704,21 +704,15 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) {
704704
return this;
705705
};
706706

707-
ClientRequest.prototype.setNoDelay = function setNoDelay() {
708-
const argsLen = arguments.length;
709-
const args = new Array(argsLen);
710-
for (var i = 0; i < argsLen; i++)
711-
args[i] = arguments[i];
712-
this._deferToConnect('setNoDelay', args);
713-
};
714-
ClientRequest.prototype.setSocketKeepAlive = function setSocketKeepAlive() {
715-
const argsLen = arguments.length;
716-
const args = new Array(argsLen);
717-
for (var i = 0; i < argsLen; i++)
718-
args[i] = arguments[i];
719-
this._deferToConnect('setKeepAlive', args);
707+
ClientRequest.prototype.setNoDelay = function setNoDelay(noDelay) {
708+
this._deferToConnect('setNoDelay', [noDelay]);
720709
};
721710

711+
ClientRequest.prototype.setSocketKeepAlive =
712+
function setSocketKeepAlive(enable, initialDelay) {
713+
this._deferToConnect('setKeepAlive', [enable, initialDelay]);
714+
};
715+
722716
ClientRequest.prototype.clearTimeout = function clearTimeout(cb) {
723717
this.setTimeout(0, cb);
724718
};

0 commit comments

Comments
 (0)
Please sign in to comment.