Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array(PR#1016)
Home

[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]
To: jdorje@xxxxxxxxxxxx
Cc: freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array(PR#1016)
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Tue, 23 Oct 2001 21:26:19 -0400

At 10:59 PM 01/10/21 -0400, Jason Dorje Short wrote:
>"Ross W. Wetmore" wrote:
>> In this case do the computation once and stash it in an array.
>> Then do an array lookup.
>
>Do you have actual evidence that that is faster?  Several comparisons
>are necessary to look up an index in an array, whereas Raimar's code
>makes 4.5 comparisons to constant values (memory positions) on average.

Huh? Where I come from an array lookup is a single load operation :-).

Cheers,
RossW
=====

>The code in question was:
>
>> 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);
>
>



[Prev in Thread] Current Thread [Next in Thread]