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‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function connect(){
7373
socket.setTimeout(options.timeout);
7474
}
7575

76-
returnSocket.prototype.connect.call(socket,options,cb);
76+
returnrealConnect.call(socket,options,cb);
7777
}
7878

7979

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

906+
functionrealConnect(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
returnthis;
943-
};
947+
}
944948

945949

946950
functionlookupAndConnect(self,options){

0 commit comments

Comments
(0)