Author: cazfi
Date: Thu Jan  1 09:24:55 2015
New Revision: 27467

URL: http://svn.gna.org/viewcvs/freeciv?rev=27467&view=rev
Log:
Made unit_owner() and unit_tile() macros to avoid function call overhead

See patch #5633

Modified:
    trunk/common/unit.c
    trunk/common/unit.h

Modified: trunk/common/unit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.c?rev=27467&r1=27466&r2=27467&view=diff
==============================================================================
--- trunk/common/unit.c (original)
+++ trunk/common/unit.c Thu Jan  1 09:24:55 2015
@@ -1446,32 +1446,12 @@
 }
 
 /**************************************************************************
-  Return the owner of the unit.
-**************************************************************************/
-struct player *unit_owner(const struct unit *punit)
-{
-  fc_assert_ret_val(NULL != punit, NULL);
-  fc_assert(NULL != punit->owner);
-  return punit->owner;
-}
-
-/**************************************************************************
   Return the nationality of the unit.
 **************************************************************************/
 struct player *unit_nationality(const struct unit *punit)
 {
   fc_assert_ret_val(NULL != punit, NULL);
   return punit->nationality;
-}
-
-/**************************************************************************
-  Return the tile location of the unit.
-  Not (yet) always used, mostly for debugging.
-**************************************************************************/
-struct tile *unit_tile(const struct unit *punit)
-{
-  fc_assert_ret_val(NULL != punit, NULL);
-  return punit->tile;
 }
 
 /*****************************************************************************

Modified: trunk/common/unit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.h?rev=27467&r1=27466&r2=27467&view=diff
==============================================================================
--- trunk/common/unit.h (original)
+++ trunk/common/unit.h Thu Jan  1 09:24:55 2015
@@ -309,9 +309,9 @@
 
 int get_transporter_capacity(const struct unit *punit);
 
-struct player *unit_owner(const struct unit *punit);
+#define unit_owner(_pu) ((_pu)->owner)
+#define unit_tile(_pu) ((_pu)->tile)
 struct player *unit_nationality(const struct unit *punit);
-struct tile *unit_tile(const struct unit *punit);
 void unit_tile_set(struct unit *punit, struct tile *ptile);
 
 struct unit *is_allied_unit_tile(const struct tile *ptile,


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

Reply via email to