Skip to content

Commit

Permalink
Merge pull request #141 from glangford/getFix
Browse files Browse the repository at this point in the history
Use associative array rather than linear search to find airport fixes
  • Loading branch information
zlsa committed Aug 20, 2015
2 parents 3c8a7b7 + d86bdb0 commit a916c90
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions assets/scripts/airport.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ var Airport=Fiber.extend(function() {
if(data.fixes) {
for(var i in data.fixes) {
var coord = new Position(data.fixes[i], this.position);
this.fixes[i] = coord.position;
this.fixes[i.toUpperCase()] = coord.position;
}
}

Expand Down Expand Up @@ -372,11 +372,7 @@ var Airport=Fiber.extend(function() {
},
getFix: function(name) {
if(!name) return null;
name = name.toLowerCase();
for(var i in this.fixes) {
if(i.toLowerCase() == name) return this.fixes[i];
}
return null;
return this.fixes[name.toUpperCase()] || null;
},
getRunway: function(name) {
if(!name) return null;
Expand Down

0 comments on commit a916c90

Please sign in to comment.