Skip to content

Commit

Permalink
http: use direct parameters instead
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
JacksonTian authored and evanlucas committed Jan 31, 2017
1 parent 438a98c commit 4c0f297
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,21 +704,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);
};

0 comments on commit 4c0f297

Please sign in to comment.