Codechange: migrate aystar to use YAPF's nodelist infrastructure #12670
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
Both aystar and YAPF have node lists with open/closed nodes and a priority queue. Heck, they are even based on the same code because both refer to the same website for the idea. So essentially we got the same code twice.
Next to that there's manual memory management with
free
,malloc
and friends. @PeterN suggested to callFree
from the destructor, but not having that at all is even better.Description
Replace aystar's queue/hash tables with YAPF's incantations, and remove the C-style variants.
Replace C-style array with count, with std::vector for the neighbours. After all, it allocates 12 though there can be at most 4 potential neighbours.
Limitations
There are many things that could be done better in the code, but I'd deliberately chosen to stop here and not completely rewrite the code to keep reviewing this feasible.
Think of not using void pointers for "user data" with the associated nasty casts, or using references instead of pointers.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.