2022-June-10 - Prerelease - 2.6.886
Pre-release
Pre-release
Refactoring TechTracker in preparation for caching techs. (#10607) This a precursor PR for allowing TechTracker to cache technology bonuses. When the cache is enabled, I've observed 26% improvement in average runtime of MustFightBattle.fight() on Domination 1914 (across hundreds of thousands of battles done by the AI - the improvement varies per map). The improvement is so drastic because a lot of work was being done summing tech bonuses just for getting the strength of one unit, for example. This PR does not yet enable the caching, since the important thing to get right is when the cache should be invalidated, which I want to be careful about and do more testing and code inspection. However, it sets everything up such that the caching can be done in a minimal follow-up PR without needing refactoring. Some code is moved from TechAttachment to TechTracker as well as the corresponding unit tests and various callers are updated to take different params so that they can use an instance of TechTracker to lookup tech bonuses. No functional changes. Some small perf improvements due to code restructuring (e.g. moving computations outside of loops).