[Freeciv-Dev] (PR#6165) use memset instead of iteration
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Greg had some concern over the slowdown caused by using an iterator to
initialize the warmaps.
Of course, we can still use memset. The only drawback is that the array
elements must all be byte-sized.
jason
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.173
diff -u -r1.173 gotohand.c
--- server/gotohand.c 2003/08/01 15:58:08 1.173
+++ server/gotohand.c 2003/09/15 20:38:18
@@ -208,15 +208,13 @@
case LAND_MOVING:
case HELI_MOVING:
case AIR_MOVING:
- whole_map_iterate(x, y) {
- WARMAP_COST(x, y) = MAXCOST;
- } whole_map_iterate_end;
+ assert(sizeof(*warmap.cost) == sizeof(char));
+ memset(warmap.cost, MAXCOST, map.xsize * map.ysize);
WARMAP_COST(orig_x, orig_y) = 0;
break;
case SEA_MOVING:
- whole_map_iterate(x, y) {
- WARMAP_SEACOST(x, y) = MAXCOST;
- } whole_map_iterate_end;
+ assert(sizeof(*warmap.seacost) == sizeof(char));
+ memset(warmap.seacost, MAXCOST, map.xsize * map.ysize);
WARMAP_SEACOST(orig_x, orig_y) = 0;
break;
default:
@@ -813,9 +811,8 @@
/*** Succeeded. The vector at the destination indicates which way we get
there.
Now backtrack to remove all the blind paths ***/
- whole_map_iterate(x, y) {
- WARMAP_VECTOR(x, y) = 0;
- } whole_map_iterate_end;
+ assert(sizeof(*warmap.vector) == sizeof(char));
+ memset(warmap.vector, 0, map.xsize * map.ysize);
init_queue();
add_to_mapqueue(0, dest_x, dest_y);
- [Freeciv-Dev] (PR#6165) use memset instead of iteration,
Jason Short <=
|
|