mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 20:15:35 +00:00
3b9e94ddb9
## Description: When drawing the border colors, the territory layer is using the generic `nearbyUnit` function to check if any allied outpost is nearby. But `nearbyUnit` is uselesly computing the distance with all units, which is very costly specially in late games with plenty of units. Early game (<1 min):  Late game (> 10 min):  This PR adds another function tailored for this requirement. ## Improvements: - New `hasNearbyUnit()` function stopping at the first correct unit, rather than computing the distance with every unit - Check the unit type before computing its distance - Selecting the correct cells: The previous algorithm was very generous and looking at cells uselessly. Admittedly this is marginal but since it is called on every border pixel change, we should squeeze the most performances out of it.  Performances after (with bots): Early:  Late:  Both Chrome and Firefox seems to benefit from it: Previous behavior on chrome:  After:  ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: IngloriousTom