[Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array (PR#1016)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Why do you *always* go for the O(n) solution to any problem?
Is this a conspiracy to slow down the codebase?
In this case do the computation once and stash it in an array.
Then do an array lookup.
If you put this where the enums are assigned, then you can even
define it statically with a note to make sure you change the two
elements in tandem.
Every time you add one of the "little" inefficiencies you are
killing the performance. It may be the death of a thousand cuts,
but you seem to be very prolific at cutting, and the fixes will
be a thousand fixes to recover.
Cheers,
RossW
=====
At 05:36 PM 01/10/17 -0400, Jason Dorje Short wrote:
>Jason Dorje Short wrote:
>>
>> Raimar Falke wrote:
>Index: common/map.h
>===================================================================
>RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
>retrieving revision 1.99
>diff -u -r1.99 map.h
>--- common/map.h 2001/10/15 13:42:51 1.99
>+++ common/map.h 2001/10/17 21:32:57
>@@ -220,6 +220,34 @@
> (dest_y) += (src_y), \
> normalize_map_pos(&(dest_x), &(dest_y)))
>
>+/*
>+ * Returns the next direction clock-wise
>+ */
>+#define DIR_CW(dir) \
>+ ((dir)==DIR8_WEST ? DIR8_NORTHWEST : \
>+ ((dir)==DIR8_EAST ? DIR8_SOUTHEAST : \
>+ ((dir)==DIR8_NORTH ? DIR8_NORTHEAST : \
>+ ((dir)==DIR8_SOUTH ? DIR8_SOUTHWEST : \
>+ ((dir)==DIR8_NORTHWEST ? DIR8_NORTH : \
>+ ((dir)==DIR8_NORTHEAST ? DIR8_EAST : \
>+ ((dir)==DIR8_SOUTHWEST ? DIR8_WEST : \
>+ ((dir)==DIR8_SOUTHEAST ? DIR8_SOUTH : \
>+ (dir)/0))))))))
>+
>+/*
>+ * Returns the next direction counter-clock-wise
>+ */
>+#define DIR_CCW(dir) \
>+ ((dir)==DIR8_WEST ? DIR8_SOUTHWEST : \
>+ ((dir)==DIR8_EAST ? DIR8_NORTHEAST : \
>+ ((dir)==DIR8_NORTH ? DIR8_NORTHWEST : \
>+ ((dir)==DIR8_SOUTH ? DIR8_SOUTHEAST : \
>+ ((dir)==DIR8_NORTHWEST ? DIR8_WEST : \
>+ ((dir)==DIR8_NORTHEAST ? DIR8_NORTH : \
>+ ((dir)==DIR8_SOUTHWEST ? DIR8_SOUTH : \
>+ ((dir)==DIR8_SOUTHEAST ? DIR8_EAST : \
>+ (dir)/0))))))))
>+
> struct city *map_get_city(int x, int y);
> void map_set_city(int x, int y, struct city *pcity);
> enum tile_terrain_type map_get_terrain(int x, int y);
- [Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array (PR#1016),
Ross W. Wetmore <=
|
|