diff options
author | Nathan Woltman <nwoltman@outlook.com> | 2015-12-20 02:01:34 -0500 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-03-10 18:45:08 -0800 |
commit | d0582ef9e19e8ed941b0a585c935ad11919080ee (patch) | |
tree | 867f8ef85cb0b7bafef37ee5bd96f7f4868baae1 /lib/_http_client.js | |
parent | 0ea3899cabfebc764b8dedbd64d306b54db81fa6 (diff) | |
download | node-new-d0582ef9e19e8ed941b0a585c935ad11919080ee.tar.gz |
lib: copy arguments object instead of leaking it
Instead of leaking the arguments object by passing it as an
argument to a function, copy it's contents to a new array,
then pass the array. This allows V8 to optimize the function
that contains this code, improving performance.
PR-URL: https://github.com/nodejs/node/pull/4361
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'lib/_http_client.js')
-rw-r--r-- | lib/_http_client.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js index 81fa5dabd4..2b37ad1a82 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -608,10 +608,18 @@ ClientRequest.prototype.setTimeout = function(msecs, callback) { }; ClientRequest.prototype.setNoDelay = function() { - this._deferToConnect('setNoDelay', arguments); + 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() { - this._deferToConnect('setKeepAlive', arguments); + 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.clearTimeout = function(cb) { |