Skip to content

Commit 94385c6

Browse files
bnoordhuisevanlucas
authored andcommitted
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: #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 0e40e6d commit 94385c6

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
@@ -73,7 +73,7 @@ function connect() {
7373
socket.setTimeout(options.timeout);
7474
}
7575

76-
return Socket.prototype.connect.call(socket, options, cb);
76+
return realConnect.call(socket, options, cb);
7777
}
7878

7979

@@ -899,7 +899,11 @@ Socket.prototype.connect = function() {
899899
const normalized = normalizeArgs(args);
900900
const options = normalized[0];
901901
const cb = normalized[1];
902+
return realConnect.call(this, options, cb);
903+
};
904+
902905

906+
function realConnect(options, cb) {
903907
if (this.write !== Socket.prototype.write)
904908
this.write = Socket.prototype.write;
905909

@@ -940,7 +944,7 @@ Socket.prototype.connect = function() {
940944
lookupAndConnect(this, options);
941945
}
942946
return this;
943-
};
947+
}
944948

945949

946950
function lookupAndConnect(self, options) {

0 commit comments

Comments
 (0)