Skip to content

Commit 4c21204

Browse files
committed
Remove useless local variables in Graph constructor
1 parent 5e55d05 commit 4c21204

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

astar.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,21 @@ var astar = {
166166
* @param {bool} [diagonal] Specify whether diagonal moves are allowed
167167
*/
168168
function Graph(gridIn, diagonal) {
169-
var nodes = [];
169+
this.nodes = [];
170+
this.diagonal = !!diagonal; // Optionally find diagonal neighbors as well (false by default).
170171

171172
if (gridIn) {
172-
var grid = [],
173-
node;
173+
this.grid = [];
174174
for (var x = 0; x < gridIn.length; x++) {
175-
grid[x] = [];
175+
this.grid[x] = [];
176176

177177
for (var y = 0, row = gridIn[x]; y < row.length; y++) {
178-
node = new GraphNode(x, y, row[y]);
179-
grid[x][y] = node;
180-
nodes.push(node);
178+
var node = new GraphNode(x, y, row[y]);
179+
this.grid[x][y] = node;
180+
this.nodes.push(node);
181181
}
182182
}
183-
this.grid = grid;
184183
}
185-
186-
this.nodes = nodes;
187-
this.diagonal = !!diagonal; // Optionally find diagonal neighbors as well (false by default).
188184
}
189185

190186
Graph.prototype.add = function(node) {

0 commit comments

Comments
 (0)