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/_tls_wrap.js | |
parent | 0ea3899cabfebc764b8dedbd64d306b54db81fa6 (diff) | |
download | android-node-v8-d0582ef9e19e8ed941b0a585c935ad11919080ee.tar.gz android-node-v8-d0582ef9e19e8ed941b0a585c935ad11919080ee.tar.bz2 android-node-v8-d0582ef9e19e8ed941b0a585c935ad11919080ee.zip |
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/_tls_wrap.js')
-rw-r--r-- | lib/_tls_wrap.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index cbeb48c072..697fbfa3e5 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -960,7 +960,11 @@ function normalizeConnectArgs(listArgs) { } exports.connect = function(/* [port, host], options, cb */) { - var args = normalizeConnectArgs(arguments); + const argsLen = arguments.length; + var args = new Array(argsLen); + for (var i = 0; i < argsLen; i++) + args[i] = arguments[i]; + args = normalizeConnectArgs(args); var options = args[0]; var cb = args[1]; |