Skip to content

Commit 31874a7

Browse files
mscdexevanlucas
authored andcommitted
net: fix permanent deoptimizations
PR-URL: #12456 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 15bfec2 commit 31874a7

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lib/net.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ function createServer(options, connectionListener) {
6060
// connect(path, [cb]);
6161
//
6262
function connect() {
63-
const args = new Array(arguments.length);
63+
var args = new Array(arguments.length);
6464
for (var i = 0; i < arguments.length; i++)
6565
args[i] = arguments[i];
6666
// TODO(joyeecheung): use destructuring when V8 is fast enough
67-
const normalized = normalizeArgs(args);
68-
const options = normalized[0];
69-
const cb = normalized[1];
67+
var normalized = normalizeArgs(args);
68+
var options = normalized[0];
69+
var cb = normalized[1];
7070
debug('createConnection', normalized);
71-
const socket = new Socket(options);
71+
var socket = new Socket(options);
7272

7373
if (options.timeout) {
7474
socket.setTimeout(options.timeout);
@@ -893,13 +893,13 @@ function internalConnect(
893893

894894

895895
Socket.prototype.connect = function() {
896-
const args = new Array(arguments.length);
896+
var args = new Array(arguments.length);
897897
for (var i = 0; i < arguments.length; i++)
898898
args[i] = arguments[i];
899899
// TODO(joyeecheung): use destructuring when V8 is fast enough
900-
const normalized = normalizeArgs(args);
901-
const options = normalized[0];
902-
const cb = normalized[1];
900+
var normalized = normalizeArgs(args);
901+
var options = normalized[0];
902+
var cb = normalized[1];
903903
return realConnect.call(this, options, cb);
904904
};
905905

@@ -1350,19 +1350,19 @@ function listenInCluster(server, address, port, addressType,
13501350

13511351

13521352
Server.prototype.listen = function() {
1353-
const args = new Array(arguments.length);
1353+
var args = new Array(arguments.length);
13541354
for (var i = 0; i < arguments.length; i++)
13551355
args[i] = arguments[i];
13561356
// TODO(joyeecheung): use destructuring when V8 is fast enough
1357-
const normalized = normalizeArgs(args);
1357+
var normalized = normalizeArgs(args);
13581358
var options = normalized[0];
1359-
const cb = normalized[1];
1359+
var cb = normalized[1];
13601360

13611361
var hasCallback = (cb !== null);
13621362
if (hasCallback) {
13631363
this.once('listening', cb);
13641364
}
1365-
const backlogFromArgs =
1365+
var backlogFromArgs =
13661366
// (handle, backlog) or (path, backlog) or (port, backlog)
13671367
toNumber(args.length > 1 && args[1]) ||
13681368
toNumber(args.length > 2 && args[2]); // (port, host, backlog)
@@ -1391,11 +1391,12 @@ Server.prototype.listen = function() {
13911391
// ([port][, host][, backlog][, cb]) where port is specified
13921392
// or (options[, cb]) where options.port is specified
13931393
// or if options.port is normalized as 0 before
1394+
var backlog;
13941395
if (typeof options.port === 'number' || typeof options.port === 'string') {
13951396
if (!isLegalPort(options.port)) {
13961397
throw new RangeError('"port" argument must be >= 0 and < 65536');
13971398
}
1398-
const backlog = options.backlog || backlogFromArgs;
1399+
backlog = options.backlog || backlogFromArgs;
13991400
// start TCP server listening on host:port
14001401
if (options.host) {
14011402
lookupAndListen(this, options.port | 0, options.host, backlog,
@@ -1411,8 +1412,8 @@ Server.prototype.listen = function() {
14111412
// (path[, backlog][, cb]) or (options[, cb])
14121413
// where path or options.path is a UNIX domain socket or Windows pipe
14131414
if (options.path && isPipeName(options.path)) {
1414-
const pipeName = this._pipeName = options.path;
1415-
const backlog = options.backlog || backlogFromArgs;
1415+
var pipeName = this._pipeName = options.path;
1416+
backlog = options.backlog || backlogFromArgs;
14161417
listenInCluster(this, pipeName, -1, -1,
14171418
backlog, undefined, options.exclusive);
14181419
return this;

0 commit comments

Comments
 (0)