From 96247a04d3cc1545c595860e5a8a8d8f388423d1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 2 Feb 2023 05:45:43 +0200 Subject: [PATCH 42/42] city_tile_iterate(): Evaluate _city_tile just once See osdn #46534 Signed-off-by: Marko Lindqvist --- common/city.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/common/city.h b/common/city.h index aac8205607..679f964da9 100644 --- a/common/city.h +++ b/common/city.h @@ -211,17 +211,18 @@ void citylog_map_workers(enum log_level level, struct city *pcity); } city_map_iterate_end; \ } -/* Does the same thing as city_tile_iterate_index, but keeps the city +/* Does the same thing as city_tile_iterate_index(), but keeps the city * coordinates hidden. */ #define city_tile_iterate(_radius_sq, _city_tile, _tile) { \ - city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \ - _radius_sq, _x, _y) \ - struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq, \ - _x, _y); \ + const struct tile *_center##_tile = _city_tile; \ + city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \ + _radius_sq, _x, _y) \ + struct tile *_tile = city_map_to_tile(_center##_tile, _radius_sq, \ + _x, _y); \ if (NULL != _tile) { -#define city_tile_iterate_end \ - } \ +#define city_tile_iterate_end \ + } \ } city_map_iterate_outwards_radius_sq_end; /* Improvement status (for cities' lists of improvements) -- 2.39.1