Skip to content

Commit bb06add

Browse files
committed
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: nodejs#12342 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9433434 commit bb06add

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/net.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function connect() {
9494
socket.setTimeout(options.timeout);
9595
}
9696

97-
return Socket.prototype.connect.call(socket, options, cb);
97+
return realConnect.call(socket, options, cb);
9898
}
9999

100100

@@ -921,7 +921,11 @@ Socket.prototype.connect = function() {
921921
const normalized = normalizeArgs(args);
922922
const options = normalized[0];
923923
const cb = normalized[1];
924+
return realConnect.call(this, options, cb);
925+
};
926+
924927

928+
function realConnect(options, cb) {
925929
if (this.write !== Socket.prototype.write)
926930
this.write = Socket.prototype.write;
927931

@@ -962,7 +966,7 @@ Socket.prototype.connect = function() {
962966
lookupAndConnect(this, options);
963967
}
964968
return this;
965-
};
969+
}
966970

967971

968972
function lookupAndConnect(self, options) {

0 commit comments

Comments
 (0)