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.
  • Loading branch information
JacksonTian committed Jan 20, 2017
1 parent 98bb65f commit 75b63b2
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 @@ -714,21 +714,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 75b63b2

Please sign in to comment.