Opened 11 years ago
Last modified 7 years ago
#2012 closed enhancement
Cache GetPercentMapExplored — at Initial Version
Reported by: | scroogie | Owned by: | |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 14 |
Component: | Core engine | Keywords: | patch performance |
Cc: | Itms, wraitii | Patch: |
Description
In a callgrind run I've seen that CCmpRangeManager::GetPercentMapExplored showed up as an expensive function (callgrind showed 6.56 self). Its apparently called quite often for statistics gathering. The patch changes the implementation to cache the value instead of recomputing it every time, as that includes traversing all tiles of the map. Also the original implementation traverses all tiles for playerId==0, which is not required, as it will always be 0. This gave me a slightly measurable speedup in replays of full games. Its of course only faster if the function is actually called that often, of which I didn't know if its on purpose or not. Should it only be called at the end of a game? Anyway, in case it stays like this, here is a patch.