From 4a082889bd6d29512d462425fe21752b442071a2 Mon Sep 17 00:00:00 2001 From: Brian White Date: Mon, 24 Apr 2017 02:21:25 -0400 Subject: [PATCH] net: fix permanent deoptimizations PR-URL: https://github.com/nodejs/node/pull/12456 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- lib/net.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/net.js b/lib/net.js index f8329a1931ba22..71cb1e58db115a 100644 --- a/lib/net.js +++ b/lib/net.js @@ -60,15 +60,15 @@ function createServer(options, connectionListener) { // connect(path, [cb]); // function connect() { - const args = new Array(arguments.length); + var args = new Array(arguments.length); for (var i = 0; i < arguments.length; i++) args[i] = arguments[i]; // TODO(joyeecheung): use destructuring when V8 is fast enough - const normalized = normalizeArgs(args); - const options = normalized[0]; - const cb = normalized[1]; + var normalized = normalizeArgs(args); + var options = normalized[0]; + var cb = normalized[1]; debug('createConnection', normalized); - const socket = new Socket(options); + var socket = new Socket(options); if (options.timeout) { socket.setTimeout(options.timeout); @@ -893,13 +893,13 @@ function internalConnect( Socket.prototype.connect = function() { - const args = new Array(arguments.length); + var args = new Array(arguments.length); for (var i = 0; i < arguments.length; i++) args[i] = arguments[i]; // TODO(joyeecheung): use destructuring when V8 is fast enough - const normalized = normalizeArgs(args); - const options = normalized[0]; - const cb = normalized[1]; + var normalized = normalizeArgs(args); + var options = normalized[0]; + var cb = normalized[1]; return realConnect.call(this, options, cb); }; @@ -1350,19 +1350,19 @@ function listenInCluster(server, address, port, addressType, Server.prototype.listen = function() { - const args = new Array(arguments.length); + var args = new Array(arguments.length); for (var i = 0; i < arguments.length; i++) args[i] = arguments[i]; // TODO(joyeecheung): use destructuring when V8 is fast enough - const normalized = normalizeArgs(args); + var normalized = normalizeArgs(args); var options = normalized[0]; - const cb = normalized[1]; + var cb = normalized[1]; var hasCallback = (cb !== null); if (hasCallback) { this.once('listening', cb); } - const backlogFromArgs = + var backlogFromArgs = // (handle, backlog) or (path, backlog) or (port, backlog) toNumber(args.length > 1 && args[1]) || toNumber(args.length > 2 && args[2]); // (port, host, backlog) @@ -1391,11 +1391,12 @@ Server.prototype.listen = function() { // ([port][, host][, backlog][, cb]) where port is specified // or (options[, cb]) where options.port is specified // or if options.port is normalized as 0 before + var backlog; if (typeof options.port === 'number' || typeof options.port === 'string') { if (!isLegalPort(options.port)) { throw new RangeError('"port" argument must be >= 0 and < 65536'); } - const backlog = options.backlog || backlogFromArgs; + backlog = options.backlog || backlogFromArgs; // start TCP server listening on host:port if (options.host) { lookupAndListen(this, options.port | 0, options.host, backlog, @@ -1411,8 +1412,8 @@ Server.prototype.listen = function() { // (path[, backlog][, cb]) or (options[, cb]) // where path or options.path is a UNIX domain socket or Windows pipe if (options.path && isPipeName(options.path)) { - const pipeName = this._pipeName = options.path; - const backlog = options.backlog || backlogFromArgs; + var pipeName = this._pipeName = options.path; + backlog = options.backlog || backlogFromArgs; listenInCluster(this, pipeName, -1, -1, backlog, undefined, options.exclusive); return this;