Add new keyword WZ_DECL_ALWAYS_INLINE to label functions that we always want to inline, even when compiling in debug mode.

Also manually inline map tile lookups in the danger map code for maximum performance (avoiding some checks).
master
Per Inge Mathisen 2010-11-02 21:12:58 +01:00
parent b1c4980c81
commit 1617b4c3d7
3 changed files with 21 additions and 8 deletions

View File

@ -423,6 +423,19 @@
#endif
/*!
* \def WZ_DECL_ALWAYS_INLINE
* GCC: "Generally, functions are not inlined unless optimization is specified. For functions
* declared inline, this attribute inlines the function even if no optimization level
* was specified."
*/
#if WZ_CC_GNU_PREREQ(2,5)
# define WZ_DECL_ALWAYS_INLINE __attribute__((__always_inline__))
#else
# define WZ_DECL_ALWAYS_INLINE
#endif
/*!
* \def WZ_DECL_PURE
* GCC: "Many functions have no effects except the return value and their return value depends

View File

@ -1560,7 +1560,7 @@ static void dangerFloodFill(int player)
do
{
MAPTILE *currTile = mapTile(pos.x, pos.y);
MAPTILE *currTile = &psMapTiles[pos.x + (pos.y * mapWidth)];
// Add accessible neighbouring tiles to the open list
for (i = 0; i < NUM_DIR; i++)
@ -1572,7 +1572,7 @@ static void dangerFloodFill(int player)
{
continue;
}
psTile = mapTile(npos.x, npos.y);
psTile = &psMapTiles[npos.x + (npos.y * mapWidth)];
if (!(psTile->tileInfoBits & BITS_TEMPORARY)
&& !(psTile->threatBits & (1 << player))

View File

@ -355,7 +355,7 @@ static inline void setTileHeight(SDWORD x, SDWORD y, float height)
}
/* Return whether a tile coordinate is on the map */
static inline BOOL tileOnMap(SDWORD x, SDWORD y)
WZ_DECL_ALWAYS_INLINE static inline BOOL tileOnMap(SDWORD x, SDWORD y)
{
return (x >= 0) && (x < (SDWORD)mapWidth) && (y >= 0) && (y < (SDWORD)mapHeight);
}
@ -368,7 +368,7 @@ static inline BOOL tileInsideBuildRange(SDWORD x, SDWORD y)
}
/* Return whether a world coordinate is on the map */
static inline BOOL worldOnMap(int x, int y)
WZ_DECL_ALWAYS_INLINE static inline BOOL worldOnMap(int x, int y)
{
return (x >= 0) && (x < ((SDWORD)mapWidth << TILE_SHIFT)) &&
(y >= 0) && (y < ((SDWORD)mapHeight << TILE_SHIFT));
@ -376,21 +376,21 @@ static inline BOOL worldOnMap(int x, int y)
/* Return whether a world coordinate is on the map */
static inline bool worldOnMap2i(Vector2i pos)
WZ_DECL_ALWAYS_INLINE static inline bool worldOnMap2i(Vector2i pos)
{
return worldOnMap(pos.x, pos.y);
}
/* Return whether a world coordinate is on the map */
static inline bool worldOnMap3i(Vector3i pos)
WZ_DECL_ALWAYS_INLINE static inline bool worldOnMap3i(Vector3i pos)
{
return worldOnMap(pos.x, pos.y);
}
/* Return whether a world coordinate is on the map */
static inline bool worldOnMap3f(Vector3f pos)
WZ_DECL_ALWAYS_INLINE static inline bool worldOnMap3f(Vector3f pos)
{
return worldOnMap(pos.x, pos.y);
}
@ -432,7 +432,7 @@ extern bool fireOnLocation(unsigned int x, unsigned int y);
* Transitive sensor check for tile. Has to be here rather than
* visibility.h due to header include order issues.
*/
static inline bool hasSensorOnTile(MAPTILE *psTile, unsigned player)
WZ_DECL_ALWAYS_INLINE static inline bool hasSensorOnTile(MAPTILE *psTile, unsigned player)
{
return ((player == selectedPlayer && godMode) || (alliancebits[selectedPlayer] & (satuplinkbits | psTile->sensorBits)));
}