-
Notifications
You must be signed in to change notification settings - Fork 117
refactor(pathfinding): simplify functions to improve readability - Part 2 #1620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(pathfinding): simplify functions to improve readability - Part 2 #1620
Conversation
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of merging multiple conditions into a single conditions. It loses the ability to put breakpoints in the debugger. I suggest to preserve the EA condition style because that helps debugging.
It's the only way to gain extra performance while maintaining retail compatibility, this code is pretty performance critical to the game and every extra if statement is a new possible branch miss and cache flush. Combining conditionals that produce the same result has significantly less overhead than checking every one individually. |
Can you proof this with godbolt please? |
|
I have to second @xezon on that one, in my experience reversing these games, combining conditionals doesn't really decrease the number of comparisons as each condition still has to be jumped to and evaluated as part of the combined statement. |
i might have been thinking of a different situation, i was sure i had read around that combining conditionals reduced branching. I will revert some of the combining of conditionals and make them clearer to understand. |
0687642 to
3a9d92c
Compare
|
Tweaked based on feedback |
3a9d92c to
ae7cfaf
Compare
|
That ones all tweaked based on feedback |
11bfe57 to
21dad4d
Compare
|
Needs to be replicated to Generals |
|
will replicate across to generals soon, theres some further tweaks that i can do which requires part 1 to be merged first since it adds the checkCellOutsideExtents function that can be applied to some of the functions in this PR. |
21dad4d to
43074a8
Compare
|
rebase with main before changes |
…:internalFindPath (#1620)
…:validLocomotorSurfacesForCellType (#1620)
…:findAttackPath (#1620)
…:getMoveAwayFromPath (#1620)
|
Minor difference in |
43074a8 to
6892d82
Compare
|
Should be good now |
…:validLocomotorSurfacesForCellType (#1620)
…:validLocomotorSurfacesForCellType (TheSuperHackers#1620)
…:getMoveAwayFromPath (TheSuperHackers#1620)
Merge with rebase
Part 2 in this epic series of munkee magic.
This PR cleans up various functions within the pathfinding, the goal to improve readability where possible and to improve performance where possible.
I have broken each function down into it's own commit to aid review.
This PR covers the functions
A few of the refactors cover code simplification by inverting the logic and returning early or by simplifying functionality.
Todo