net: fix permanent deoptimizations
PR-URL: https://github.com/nodejs/node/pull/12456 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Родитель
d5925af8d7
Коммит
3c098ee7e2
33
lib/net.js
33
lib/net.js
|
@ -81,15 +81,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);
|
||||
|
@ -915,13 +915,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);
|
||||
};
|
||||
|
||||
|
@ -1373,19 +1373,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)
|
||||
|
@ -1414,11 +1414,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,
|
||||
|
@ -1434,8 +1435,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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче