Skip to content
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

Optimize hasNationZone() method. #4312

Merged
merged 1 commit into from
Sep 15, 2020
Merged

Optimize hasNationZone() method. #4312

merged 1 commit into from
Sep 15, 2020

Conversation

silverwolfg11
Copy link
Contributor

Description:

Optimizes the hasNationZone() method in the TownyAPI. This is done by removing the duplicate distance check and instead returning the closest townblock to a Coord 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.


  • I have tested this pull request for defects on a server.

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.

@LlmDl LlmDl merged commit 8222423 into master Sep 15, 2020
@LlmDl LlmDl deleted the perf/optimize-hasnationzone branch September 15, 2020 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants