Skip to content

Commit 6502160

Browse files
mscdexjasnell
authored andcommitted
dns: allow v8 to optimize lookup()
Using `arguments` and reassigning parameter variable values causes v8 to disable function optimization. PR-URL: nodejs/node-v0.x-archive#8942 Reviewed-By: jasnell - James M Snell <[email protected]>
1 parent 66ec1da commit 6502160

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/dns.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
var cares = process.binding('cares_wrap'),
2323
net = require('net'),
24-
isIp = net.isIP;
24+
isIP = net.isIP;
2525

2626

2727
function errnoException(errorno, syscall) {
@@ -78,7 +78,9 @@ function makeAsync(callback) {
7878

7979
// Easy DNS A/AAAA look up
8080
// lookup(domain, [family,] callback)
81-
exports.lookup = function(domain, family, callback) {
81+
exports.lookup = function(domain, family_, callback_) {
82+
var family = family_,
83+
callback = callback_;
8284
// parse arguments
8385
if (arguments.length === 2) {
8486
callback = family;
@@ -102,12 +104,12 @@ exports.lookup = function(domain, family, callback) {
102104
// localhost entry from c:\WINDOWS\system32\drivers\etc\hosts
103105
// See http://daniel.haxx.se/blog/2011/02/21/localhost-hack-on-windows/
104106
// TODO Remove this once c-ares handles this problem.
105-
if (process.platform == 'win32' && domain == 'localhost') {
107+
if (process.platform === 'win32' && domain === 'localhost') {
106108
callback(null, '127.0.0.1', 4);
107109
return {};
108110
}
109111

110-
var matchedFamily = net.isIP(domain);
112+
var matchedFamily = isIP(domain);
111113
if (matchedFamily) {
112114
callback(null, domain, matchedFamily);
113115
return {};

0 commit comments

Comments
 (0)