Skip to content

Commit

Permalink
net: fix permanent deoptimizations
Browse files Browse the repository at this point in the history
PR-URL: #12456
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mscdex authored and evanlucas committed May 2, 2017
1 parent 15bfec2 commit 31874a7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
};

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 31874a7

Please sign in to comment.