arjunmehta / node-geo-proximity

Super fast proximity searches of geo coordinates.
MIT License
132 stars 18 forks source link

Unnecessary global variables. #17

Closed saby1101 closed 9 years ago

saby1101 commented 9 years ago

module was failing when run with '--use-strict' flag.

arjunmehta commented 9 years ago

Thank you for catching this: Instead of redeclaring the range every iteration, please pull the range declaration out of the loop to the top of the method. Will accept PR then!

function increaseRangeBitDepth(ranges, radiusBitDepth, bitDepth) {

    var bitDiff = bitDepth - radiusBitDepth;
    var range;

    for (var i = 0; i < ranges.length; i++) {
        range = ranges[i];
        range[0] = leftShift(range[0], bitDiff);
        range[1] = leftShift(range[1], bitDiff);
    }
}
saby1101 commented 9 years ago

I don't think it matters. Look at this..http://stackoverflow.com/questions/3684923/javascript-variables-declare-outside-or-inside-loop. Anyways thanks for fixing the bug. Keep up the good work. Cheers!

-----Original Message----- From: "Arjun Mehta" notifications@github.com Sent: ‎7/‎23/‎2015 7:22 AM To: "arjunmehta/node-geo-proximity" node-geo-proximity@noreply.github.com Cc: "Sabyasachi Bhattacharjee" sbhatt.iitk@gmail.com Subject: Re: [node-geo-proximity] Unnecessary global variables. (#17)

function increaseRangeBitDepth(ranges, radiusBitDepth, bitDepth) {

var bitDiff = bitDepth - radiusBitDepth;
var range;

for (var i = 0; i < ranges.length; i++) {
    range = ranges[i];
    range[0] = leftShift(range[0], bitDiff);
    range[1] = leftShift(range[1], bitDiff);
}

}— Reply to this email directly or view it on GitHub.

arjunmehta commented 9 years ago

Thanks!!

Yeah, it's more convention than anything else. I will probably add an .eslintrc file to the project soon! :)

saby1101 commented 9 years ago

Cool

arjunmehta commented 9 years ago

Published. Thanks again.