https: optimize https.createConnection()

Stop using `arguments` for performance and readability.
This commit is contained in:
Ryunosuke SATO 2012-12-28 12:40:06 +09:00 committed by Ben Noordhuis
parent a329729537
commit c4fc0febfa

View File

@ -57,26 +57,25 @@ exports.createServer = function(opts, requestListener) {
// HTTPS agents. // HTTPS agents.
function createConnection(/* [port, host, options] */) { function createConnection(port, host, options) {
var options = {}; if (typeof port === 'object') {
options = port;
if (typeof arguments[0] === 'object') { } else if (typeof host === 'object') {
options = arguments[0]; options = host;
} else if (typeof arguments[1] === 'object') { } else if (typeof options === 'object') {
options = arguments[1]; options = options;
options.port = arguments[0];
} else if (typeof arguments[2] === 'object') {
options = arguments[2];
options.port = arguments[0];
options.host = arguments[1];
} else { } else {
if (typeof arguments[0] === 'number') { options = {};
options.port = arguments[0];
}
if (typeof arguments[1] === 'string') {
options.host = arguments[1];
}
} }
if (typeof port === 'number') {
options.port = port;
}
if (typeof host === 'string') {
options.host = host;
}
return tls.connect(options); return tls.connect(options);
} }