From 6502160294ee86033936b1c25b645705a6760178 Mon Sep 17 00:00:00 2001 From: Brian White Date: Thu, 25 Dec 2014 17:11:42 -0500 Subject: [PATCH] dns: allow v8 to optimize lookup() Using `arguments` and reassigning parameter variable values causes v8 to disable function optimization. PR-URL: https://github.com/joyent/node/pull/8942 Reviewed-By: jasnell - James M Snell --- lib/dns.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/dns.js b/lib/dns.js index 10214790de7d08..c854372fc3431c 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -21,7 +21,7 @@ var cares = process.binding('cares_wrap'), net = require('net'), - isIp = net.isIP; + isIP = net.isIP; function errnoException(errorno, syscall) { @@ -78,7 +78,9 @@ function makeAsync(callback) { // Easy DNS A/AAAA look up // lookup(domain, [family,] callback) -exports.lookup = function(domain, family, callback) { +exports.lookup = function(domain, family_, callback_) { + var family = family_, + callback = callback_; // parse arguments if (arguments.length === 2) { callback = family; @@ -102,12 +104,12 @@ exports.lookup = function(domain, family, callback) { // localhost entry from c:\WINDOWS\system32\drivers\etc\hosts // See http://daniel.haxx.se/blog/2011/02/21/localhost-hack-on-windows/ // TODO Remove this once c-ares handles this problem. - if (process.platform == 'win32' && domain == 'localhost') { + if (process.platform === 'win32' && domain === 'localhost') { callback(null, '127.0.0.1', 4); return {}; } - var matchedFamily = net.isIP(domain); + var matchedFamily = isIP(domain); if (matchedFamily) { callback(null, domain, matchedFamily); return {};