[Freeciv-Dev] (PR#7197) optimization to base_city_map_to_map
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7197) optimization to base_city_map_to_map |
From: |
"Jason Short" <jshort@xxxxxxxxxxxxxx> |
Date: |
Sun, 4 Jan 2004 15:57:41 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7197 >
The attached patch is based on one from Marcelo in PR#6721. I've
changed the logic slightly and also dropped the border radius from 3 to 2.
It speeds up autogames by 1-3%. Savegames are identical.
jason
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.200
diff -u -r1.200 city.c
--- common/city.c 2003/12/06 20:37:59 1.200
+++ common/city.c 2004/01/04 23:54:34
@@ -137,7 +137,12 @@
assert(is_valid_city_coords(city_map_x, city_map_y));
*map_x = city_center_x + city_map_x - CITY_MAP_SIZE / 2;
*map_y = city_center_y + city_map_y - CITY_MAP_SIZE / 2;
- return normalize_map_pos(map_x, map_y);
+
+ /* We check the border first to avoid doing an unnecessary
+ * normalization; this is just an optimization. */
+ return (!IS_BORDER_MAP_POS(city_center_x, city_center_y,
+ CITY_MAP_SIZE / 2)
+ || normalize_map_pos(map_x, map_y));
}
/**************************************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7197) optimization to base_city_map_to_map,
Jason Short <=
|
|