Author: cazfi Date: Sun Apr 24 15:59:48 2016 New Revision: 32475 URL: http://svn.gna.org/viewcvs/freeciv?rev=32475&view=rev Log: Inlined tile_extras()
See patch #7127 Modified: trunk/common/tile.c trunk/common/tile.h Modified: trunk/common/tile.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/tile.c?rev=32475&r1=32474&r2=32475&view=diff ============================================================================== --- trunk/common/tile.c (original) +++ trunk/common/tile.c Sun Apr 24 15:59:48 2016 @@ -154,19 +154,27 @@ } /**************************************************************************** + Returns a bit vector of the extras present at NULL tile. +****************************************************************************/ +const bv_extras *tile_extras_null(void) +{ + static bool empty_cleared = FALSE; + + if (!empty_cleared) { + BV_CLR_ALL(empty_extras); + empty_cleared = TRUE; + } + + return &(empty_extras); +} + +/**************************************************************************** Returns a bit vector of the extras present at the tile. ****************************************************************************/ -const bv_extras *tile_extras(const struct tile *ptile) +const bv_extras *tile_extras_safe(const struct tile *ptile) { if (!ptile) { - static bool empty_cleared = FALSE; - - if (!empty_cleared) { - BV_CLR_ALL(empty_extras); - empty_cleared = TRUE; - } - - return &(empty_extras); + return tile_extras_null(); } return &(ptile->extras); Modified: trunk/common/tile.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/tile.h?rev=32475&r1=32474&r2=32475&view=diff ============================================================================== --- trunk/common/tile.h (original) +++ trunk/common/tile.h Sun Apr 24 15:59:48 2016 @@ -110,7 +110,18 @@ /* struct city *tile_worked(const struct tile *ptile); */ void tile_set_worked(struct tile *ptile, struct city *pcity); -const bv_extras *tile_extras(const struct tile *ptile); +const bv_extras *tile_extras_safe(const struct tile *ptile); +const bv_extras *tile_extras_null(void); +static inline const bv_extras *tile_extras(const struct tile *ptile) +{ + /* With this NULL check this function is actually same as tile_extras_safe(). + * We may remove the check later when callers that need _safe(), do so. */ + if (ptile == NULL) { + return tile_extras_null(); + } + return &(ptile->extras); +} + void tile_set_bases(struct tile *ptile, bv_bases bases); bool tile_has_base(const struct tile *ptile, const struct base_type *pbase); void tile_add_base(struct tile *ptile, const struct base_type *pbase); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits