Skip to content

Commit

Permalink
tls: avoid potentially deoptimizing use of arguments
Browse files Browse the repository at this point in the history
Replace use of arguments with `...args`

```
 tls/tls-connect.js dur=5 concurrency=1      -9.43 %            0.172136744
 tls/tls-connect.js dur=5 concurrency=10     29.05 %         ** 0.001108115
```

PR-URL: #11357
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
jasnell authored and italoacasas committed Feb 22, 2017
1 parent 662b0c3 commit 5f94ff6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ var proxiedMethods = [

// Proxy HandleWrap, PipeWrap and TCPWrap methods
proxiedMethods.forEach(function(name) {
tls_wrap.TLSWrap.prototype[name] = function methodProxy() {
tls_wrap.TLSWrap.prototype[name] = function methodProxy(...args) {
if (this._parent[name])
return this._parent[name].apply(this._parent, arguments);
return this._parent[name].apply(this._parent, args);
};
});

Expand Down Expand Up @@ -986,11 +986,7 @@ function normalizeConnectArgs(listArgs) {
return (cb) ? [options, cb] : [options];
}

exports.connect = function(/* [port,] [host,] [options,] [cb] */) {
const argsLen = arguments.length;
var args = new Array(argsLen);
for (var i = 0; i < argsLen; i++)
args[i] = arguments[i];
exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
args = normalizeConnectArgs(args);
var options = args[0];
var cb = args[1];
Expand Down

0 comments on commit 5f94ff6

Please sign in to comment.