Re: (PR#8992) Patch: Building ferries
"Jason Short" <[email protected]>
| Newsgroups | gmane.games.freeciv.ai |
|---|---|
| Message-ID | <[email protected]> |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8992 > Per I. Mathisen wrote: > You call is_ocean_near_tile(acity->tile) a lot of times. Perhaps we should > add a new variable bool pcity->coastal instead, since the function call > above is comparatively expensive. I would be extremely wary of adding new global data fields that will need to be kept updated. pcity->coastal would need to be updated at least every turn. In some cases it may even become stale during the course of a turn. Say the value was calculated, then unit activities/global warming/whatever was done, then it were used. The real danger is that this could cause a fatal error. If the above caused a crash, for instance, it would be extremely difficult to track down. This is a problem in many other places in the code. Adding values like this that are assumed to be correct creates many dependencies that are not easy to keep track of (or even to find). If you do use precomputed values, you should always treat them as approximations and assume they might be wrong. jason