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.
Description:
Optimizes the
hasNationZone()
method in the TownyAPI. This is done by removing the duplicate distance check and instead returning the closest townblock to aCoord
object. The method of fetching the closest townblock is also optimized removing redundant object creation, and optimizing math calls.This optimization also introduces the class
MathUtil
which provides a math utility class that contains common functions or specified optimized methods. I plan to utilize this class to optimize other distance checks in another PR coming after this one is merged.Tested on a local server with 1 town and 1 nation, feel free to test on a larger dataset. I don't expect any behavioral differences to be found between my small dataset and a large dataset.
By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the Towny License for perpetuity.