Use squared values and functions for comparisons #109738
Open
+351
−308
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.
Revival of PR #108358. I looked through each commit, and modified it a little bit, but mostly this is the work of @AThousandShips so I kept the same author on the commits.
Even if the benefits are too negligible to show up on benchmarks, I think this is still worth doing. We don't have to label this PR as performance if the performance difference isn't measurable, we could just call it code hygiene to use the squared functions where applicable because that way we're following the same guideline internally as we recommend to users ("prefer it if you need to compare vectors or need the squared distance for some formula").
The changes I made on top of ATS's work:
float
toreal_t
ingodot_body_pair_3d.cpp
, avoids a needless cast in double builds.Vector2
, thenreal_t
, thenint
).const
in a few places.