Skip to content

Commit 5f94ff6

Browse files
jasnellitaloacasas
authored andcommitted
tls: avoid potentially deoptimizing use of arguments
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]>
1 parent 662b0c3 commit 5f94ff6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/_tls_wrap.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ var proxiedMethods = [
294294

295295
// Proxy HandleWrap, PipeWrap and TCPWrap methods
296296
proxiedMethods.forEach(function(name) {
297-
tls_wrap.TLSWrap.prototype[name] = function methodProxy() {
297+
tls_wrap.TLSWrap.prototype[name] = function methodProxy(...args) {
298298
if (this._parent[name])
299-
return this._parent[name].apply(this._parent, arguments);
299+
return this._parent[name].apply(this._parent, args);
300300
};
301301
});
302302

@@ -986,11 +986,7 @@ function normalizeConnectArgs(listArgs) {
986986
return (cb) ? [options, cb] : [options];
987987
}
988988

989-
exports.connect = function(/* [port,] [host,] [options,] [cb] */) {
990-
const argsLen = arguments.length;
991-
var args = new Array(argsLen);
992-
for (var i = 0; i < argsLen; i++)
993-
args[i] = arguments[i];
989+
exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
994990
args = normalizeConnectArgs(args);
995991
var options = args[0];
996992
var cb = args[1];

0 commit comments

Comments
 (0)