Author: cazfi
Date: Sat Jan 10 21:46:47 2015
New Revision: 27606

URL: http://svn.gna.org/viewcvs/freeciv?rev=27606&view=rev
Log:
Avoid constructs like road_extra_get(extra_road_get(extra)) hidden in macro 
calls and wrapper
functions in tile_move_cost_ptrs() to optimize it a bit.

See patch #5669

Modified:
    branches/S2_6/common/base.h
    branches/S2_6/common/map.c
    branches/S2_6/common/road.h

Modified: branches/S2_6/common/base.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/base.h?rev=27606&r1=27605&r2=27606&view=diff
==============================================================================
--- branches/S2_6/common/base.h (original)
+++ branches/S2_6/common/base.h Sat Jan 10 21:46:47 2015
@@ -119,6 +119,9 @@
 void base_type_init(struct extra_type *pextra, int idx);
 void base_types_free(void);
 
+/* TODO: Change users to use extra_type_by_cause_iterate(EC_BASE...)
+ * directly instead. Especially if they need the 'extra' again and
+ * get it back from the _p with base_extra_get() */
 #define base_type_iterate(_p)                   \
 {                                                \
   extra_type_by_cause_iterate(EC_BASE, _e_) {    \

Modified: branches/S2_6/common/map.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/map.c?rev=27606&r1=27605&r2=27606&view=diff
==============================================================================
--- branches/S2_6/common/map.c  (original)
+++ branches/S2_6/common/map.c  Sat Jan 10 21:46:47 2015
@@ -721,17 +721,21 @@
   ri = restrict_infra(pplayer, t1, t2);
   cardinal_move = is_move_cardinal(t1, t2);
 
-  road_type_iterate(proad) {
+  extra_type_by_cause_iterate(EC_ROAD, pextra) {
+    struct road_type *proad = extra_road_get(pextra);
+
     if ((!ri || road_has_flag(proad, RF_UNRESTRICTED_INFRA))
-        && tile_has_road(t1, proad)
+        && tile_has_extra(t1, pextra)
         && (!pclass
-            || is_native_extra_to_uclass(road_extra_get(proad), pclass))) {
+            || is_native_extra_to_uclass(pextra, pclass))) {
       road_type_list_iterate(proad->integrators, iroad) {
+        struct extra_type *iextra = road_extra_get(iroad);
+
         if (road_provides_move_bonus(iroad)
             && cost > iroad->move_cost 
-            && tile_has_road(t2, iroad)
+            && tile_has_extra(t2, iextra)
             && (!pclass
-                || is_native_extra_to_uclass(road_extra_get(iroad), pclass))) {
+                || is_native_extra_to_uclass(iextra, pclass))) {
           switch (iroad->move_mode) {
           case RMM_CARDINAL:
             if (cardinal_move) {
@@ -762,7 +766,7 @@
         }
       } road_type_list_iterate_end;
     }
-  } road_type_iterate_end;
+  } extra_type_by_cause_iterate_end;
 
   /* UTYF_IGTER units have a maximum move cost per step. */
   if (utype_has_flag(punittype, UTYF_IGTER) && MOVE_COST_IGTER < cost) {

Modified: branches/S2_6/common/road.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/road.h?rev=27606&r1=27605&r2=27606&view=diff
==============================================================================
--- branches/S2_6/common/road.h (original)
+++ branches/S2_6/common/road.h Sat Jan 10 21:46:47 2015
@@ -138,6 +138,9 @@
 void road_integrators_cache_init(void);
 void road_types_free(void);
 
+/* TODO: Change users to use extra_type_by_cause_iterate(EC_ROAD...)
+ * directly instead. Especially if they need the 'extra' again and
+ * get it back from the _p with road_extra_get() */
 #define road_type_iterate(_p)                    \
 {                                                \
   extra_type_by_cause_iterate(EC_ROAD, _e_) {    \


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to