summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyunosuke SATO <tricknotes.rs@gmail.com>2012-12-28 12:40:06 +0900
committerBen Noordhuis <info@bnoordhuis.nl>2012-12-28 16:42:51 +0100
commitc4fc0febfacf3a79ede812d44c012093b5f2e31c (patch)
tree92bef10bfc0e2aac86ae38221f0e8f7095f1ed8b
parenta3297295371720e3781c2410ebfb2ae1698b880c (diff)
downloadnode-c4fc0febfacf3a79ede812d44c012093b5f2e31c.tar.gz
https: optimize https.createConnection()
Stop using `arguments` for performance and readability.
-rw-r--r--lib/https.js35
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/https.js b/lib/https.js
index 0ed653c06..000590a76 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -57,26 +57,25 @@ exports.createServer = function(opts, requestListener) {
// HTTPS agents.
-function createConnection(/* [port, host, options] */) {
- var options = {};
-
- if (typeof arguments[0] === 'object') {
- options = arguments[0];
- } else if (typeof arguments[1] === 'object') {
- options = arguments[1];
- options.port = arguments[0];
- } else if (typeof arguments[2] === 'object') {
- options = arguments[2];
- options.port = arguments[0];
- options.host = arguments[1];
+function createConnection(port, host, options) {
+ if (typeof port === 'object') {
+ options = port;
+ } else if (typeof host === 'object') {
+ options = host;
+ } else if (typeof options === 'object') {
+ options = options;
} else {
- if (typeof arguments[0] === 'number') {
- options.port = arguments[0];
- }
- if (typeof arguments[1] === 'string') {
- options.host = arguments[1];
- }
+ options = {};
+ }
+
+ if (typeof port === 'number') {
+ options.port = port;
}
+
+ if (typeof host === 'string') {
+ options.host = host;
+ }
+
return tls.connect(options);
}