Skip to content

Commit eaea7c1

Browse files
committed
Reduce allocations when solving path in AStarGrid2D
1 parent db66bd3 commit eaea7c1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/math/a_star_grid_2d.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point, bool p_allow_
503503

504504
LocalVector<Point *> open_list;
505505
SortArray<Point *, SortPoints> sorter;
506+
LocalVector<Point *> nbors;
506507

507508
p_begin_point->g_score = 0;
508509
p_begin_point->f_score = _estimate_cost(p_begin_point->id, p_end_point->id);
@@ -528,7 +529,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point, bool p_allow_
528529
open_list.remove_at(open_list.size() - 1);
529530
p->closed_pass = pass; // Mark the point as closed.
530531

531-
LocalVector<Point *> nbors;
532+
nbors.clear();
532533
_get_nbors(p, nbors);
533534

534535
for (Point *e : nbors) {

0 commit comments

Comments
 (0)