Merge pull request #97843 from detomon/optimize-a-star-grid-2d-solve

Reduce allocations when solving path in `AStarGrid2D`
This commit is contained in:
Thaddeus Crews 2025-03-30 09:06:02 -05:00
commit 3b1a481f13
No known key found for this signature in database
GPG Key ID: 8C6E5FEB5FC03CCC

View File

@ -503,6 +503,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point, bool p_allow_
LocalVector<Point *> open_list;
SortArray<Point *, SortPoints> sorter;
LocalVector<Point *> nbors;
p_begin_point->g_score = 0;
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_
open_list.remove_at(open_list.size() - 1);
p->closed_pass = pass; // Mark the point as closed.
LocalVector<Point *> nbors;
nbors.clear();
_get_nbors(p, nbors);
for (Point *e : nbors) {