net: don't normalize twice in Socket#connect()
Split up Socket#connect() so that we don't call normalizeArgs() twice when invoking net.connect() or net.createConnection(). PR-URL: https://github.com/nodejs/node/pull/12342 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
9433434461
commit
bb06add4d7
@ -94,7 +94,7 @@ function connect() {
|
||||
socket.setTimeout(options.timeout);
|
||||
}
|
||||
|
||||
return Socket.prototype.connect.call(socket, options, cb);
|
||||
return realConnect.call(socket, options, cb);
|
||||
}
|
||||
|
||||
|
||||
@ -921,7 +921,11 @@ Socket.prototype.connect = function() {
|
||||
const normalized = normalizeArgs(args);
|
||||
const options = normalized[0];
|
||||
const cb = normalized[1];
|
||||
return realConnect.call(this, options, cb);
|
||||
};
|
||||
|
||||
|
||||
function realConnect(options, cb) {
|
||||
if (this.write !== Socket.prototype.write)
|
||||
this.write = Socket.prototype.write;
|
||||
|
||||
@ -962,7 +966,7 @@ Socket.prototype.connect = function() {
|
||||
lookupAndConnect(this, options);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function lookupAndConnect(self, options) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user