(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
smatz 13 years ago
parent 88f1acd26b
commit 33d283fdb1

@ -50,7 +50,7 @@ struct AircraftCache {
/**
* Aircraft, helicopters, rotors and their shadows belong to this class.
*/
struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
uint16 crashed_counter; ///< Timer for handling crash animations.
byte pos; ///< Next desired position of the aircraft.
byte previous_pos; ///< Previous desired position of the aircraft.

@ -15,7 +15,7 @@
#include "32bpp_optimized.hpp"
/** The optimised 32 bpp blitter with palette animation. */
class Blitter_32bppAnim : public Blitter_32bppOptimized {
class Blitter_32bppAnim FINAL : public Blitter_32bppOptimized {
private:
uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
int anim_buf_width; ///< The width of the animation buffer.

@ -16,7 +16,7 @@
#include "factory.hpp"
/** 8bpp blitter optimised for speed. */
class Blitter_8bppOptimized : public Blitter_8bppBase {
class Blitter_8bppOptimized FINAL : public Blitter_8bppBase {
public:
/** Data stored about a (single) sprite. */
struct SpriteData {

@ -16,7 +16,7 @@
#include "factory.hpp"
/** Most trivial 8bpp blitter. */
class Blitter_8bppSimple : public Blitter_8bppBase {
class Blitter_8bppSimple FINAL : public Blitter_8bppBase {
public:
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
/* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator);

@ -22,7 +22,7 @@
* - bulldozer (road works)
* - bubbles (industry)
*/
struct EffectVehicle : public SpecializedVehicle<EffectVehicle, VEH_EFFECT> {
struct EffectVehicle FINAL : public SpecializedVehicle<EffectVehicle, VEH_EFFECT> {
uint16 animation_state; ///< State primarily used to change the graphics/behaviour.
byte animation_substate; ///< Sub state to time the change of the graphics/behaviour.

@ -84,7 +84,7 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length = false);
/**
* Buses, trucks and trams belong to this class.
*/
struct RoadVehicle : public GroundVehicle<RoadVehicle, VEH_ROAD> {
struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
byte state; ///< @see RoadVehicleStates
byte frame;
uint16 blocked_ctr;

@ -21,7 +21,7 @@ WaterClass GetEffectiveWaterClass(TileIndex tile);
/**
* All ships have this type.
*/
struct Ship: public SpecializedVehicle<Ship, VEH_SHIP> {
struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
TrackBitsByte state; ///< The "track" the ship is following.
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */

@ -197,7 +197,7 @@ private:
typedef SmallVector<Industry *, 2> IndustryVector;
/** Station data structure */
struct Station : SpecializedStation<Station, false> {
struct Station FINAL : SpecializedStation<Station, false> {
public:
RoadStop *GetPrimaryRoadStop(RoadStopType type) const
{

@ -128,6 +128,11 @@
/* Warn about functions using 'printf' format syntax. First argument determines which parameter
* is the format string, second argument is start of values passed to printf. */
#define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#define FINAL final
#else
#define FINAL
#endif
#endif /* __GNUC__ */
#if defined(__WATCOMC__)
@ -136,6 +141,7 @@
#define CDECL
#define GCC_PACK
#define WARN_FORMAT(string, args)
#define FINAL
#include <malloc.h>
#endif /* __WATCOMC__ */
@ -176,7 +182,6 @@
#pragma warning(disable: 6031) // code analyzer: Return value ignored: 'ReadFile'
#pragma warning(disable: 6255) // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
#pragma warning(disable: 6246) // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ...
#define WARN_FORMAT(string, args)
#include <malloc.h> // alloca()
#define NORETURN __declspec(noreturn)
@ -188,6 +193,8 @@
#endif
#define GCC_PACK
#define WARN_FORMAT(string, args)
#define FINAL sealed
int CDECL snprintf(char *str, size_t size, const char *format, ...) WARN_FORMAT(3, 4);
#if defined(WINCE)

@ -67,7 +67,7 @@ struct TrainCache {
/**
* 'Train' is either a loco or a wagon.
*/
struct Train : public GroundVehicle<Train, VEH_TRAIN> {
struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
TrainCache tcache;
/* Link between the two ends of a multiheaded engine */

@ -1009,7 +1009,7 @@ struct SpecializedVehicle : public Vehicle {
/**
* Disasters, like submarines, skyrangers and their shadows, belong to this class.
*/
struct DisasterVehicle : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> {
struct DisasterVehicle FINAL : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> {
SpriteID image_override; ///< Override for the default disaster vehicle sprite.
VehicleID big_ufo_destroyer_target; ///< The big UFO that this destroyer is supposed to bomb.

@ -15,7 +15,7 @@
#include "base_station_base.h"
/** Representation of a waypoint. */
struct Waypoint : SpecializedStation<Waypoint, true> {
struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number)
/**

Loading…
Cancel
Save