summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2011-12-18 17:17:18 +0000
committersmatz <smatz@openttd.org>2011-12-18 17:17:18 +0000
commit33d283fdb1710e40cff4daaabde6aa78325d4623 (patch)
tree474b5ad5f9b38019a1985a4b1a29ada6a7560260 /src
parent88f1acd26bb2d7872526e4abc89549f622bb75ea (diff)
downloadopenttd-33d283fdb1710e40cff4daaabde6aa78325d4623.tar.xz
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
Diffstat (limited to 'src')
-rw-r--r--src/aircraft.h2
-rw-r--r--src/blitter/32bpp_anim.hpp2
-rw-r--r--src/blitter/8bpp_optimized.hpp2
-rw-r--r--src/blitter/8bpp_simple.hpp2
-rw-r--r--src/effectvehicle_base.h2
-rw-r--r--src/roadveh.h2
-rw-r--r--src/ship.h2
-rw-r--r--src/station_base.h2
-rw-r--r--src/stdafx.h9
-rw-r--r--src/train.h2
-rw-r--r--src/vehicle_base.h2
-rw-r--r--src/waypoint_base.h2
12 files changed, 19 insertions, 12 deletions
diff --git a/src/aircraft.h b/src/aircraft.h
index 8ba313cfa..938aaa403 100644
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -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.
diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp
index 862a21c5d..b1a5da5b4 100644
--- a/src/blitter/32bpp_anim.hpp
+++ b/src/blitter/32bpp_anim.hpp
@@ -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.
diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp
index d6c5c8956..66fbe4091 100644
--- a/src/blitter/8bpp_optimized.hpp
+++ b/src/blitter/8bpp_optimized.hpp
@@ -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 {
diff --git a/src/blitter/8bpp_simple.hpp b/src/blitter/8bpp_simple.hpp
index b0af35e90..28102fcab 100644
--- a/src/blitter/8bpp_simple.hpp
+++ b/src/blitter/8bpp_simple.hpp
@@ -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);
diff --git a/src/effectvehicle_base.h b/src/effectvehicle_base.h
index c16ee5f53..e3403b851 100644
--- a/src/effectvehicle_base.h
+++ b/src/effectvehicle_base.h
@@ -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.
diff --git a/src/roadveh.h b/src/roadveh.h
index 3323ee9f5..516c616fd 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -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;
diff --git a/src/ship.h b/src/ship.h
index d24d29db2..6096ae055 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -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! */
diff --git a/src/station_base.h b/src/station_base.h
index 5ec337f56..a495f1691 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -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
{
diff --git a/src/stdafx.h b/src/stdafx.h
index 7120ec175..c75e4ca48 100644
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -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)
diff --git a/src/train.h b/src/train.h
index 9bc40fe97..37f64a2dc 100644
--- a/src/train.h
+++ b/src/train.h
@@ -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 */
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 3a13ec4e7..7add6b6ff 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -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.
diff --git a/src/waypoint_base.h b/src/waypoint_base.h
index 7265384d9..01c0ae173 100644
--- a/src/waypoint_base.h
+++ b/src/waypoint_base.h
@@ -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)
/**