From 71d0861be131c2a710fbb7173f265d839dd715ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 4 Oct 2016 19:14:29 +0200 Subject: [PATCH] Mark classes as final This may hint compiler to de-virtualise some calls. --- src/cmdline/CommandLine.hpp | 2 +- src/core/FileEnumerator.h | 2 +- src/core/FileStream.hpp | 2 +- src/core/Json.hpp | 2 +- src/core/MemoryStream.h | 2 +- src/core/Stopwatch.hpp | 2 +- src/drawing/engines/SoftwareDrawingEngine.cpp | 6 +++--- src/drawing/engines/opengl/CopyFramebufferShader.h | 2 +- src/drawing/engines/opengl/DrawImageShader.h | 2 +- src/drawing/engines/opengl/DrawLineShader.h | 2 +- src/drawing/engines/opengl/FillRectShader.h | 2 +- src/drawing/engines/opengl/SwapFramebuffer.h | 2 +- src/drawing/engines/opengl/TextureCache.h | 4 ++-- src/localisation/LanguagePack.cpp | 2 +- src/network/NetworkAction.h | 4 ++-- src/network/NetworkConnection.h | 2 +- src/network/NetworkGroup.h | 2 +- src/network/NetworkKey.h | 2 +- src/network/NetworkPacket.h | 2 +- src/network/NetworkPlayer.h | 2 +- src/network/NetworkUser.h | 4 ++-- src/object/BannerObject.h | 4 ++-- src/object/EntranceObject.h | 4 ++-- src/object/FootpathItemObject.h | 4 ++-- src/object/FootpathObject.h | 4 ++-- src/object/ImageTable.h | 4 ++-- src/object/LargeSceneryObject.h | 4 ++-- src/object/RideObject.h | 4 ++-- src/object/SceneryGroupObject.h | 4 ++-- src/object/SmallSceneryObject.h | 4 ++-- src/object/StexObject.h | 4 ++-- src/object/WallObject.h | 4 ++-- src/object/WaterObject.h | 4 ++-- src/rct2/S6Exporter.h | 2 +- src/rct2/S6Importer.h | 2 +- 35 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/cmdline/CommandLine.hpp b/src/cmdline/CommandLine.hpp index 4dc4bf713e..10c1365eed 100644 --- a/src/cmdline/CommandLine.hpp +++ b/src/cmdline/CommandLine.hpp @@ -25,7 +25,7 @@ extern "C" /** * Class for enumerating and retrieving values for a set of command line arguments. */ -class CommandLineArgEnumerator +class CommandLineArgEnumerator final { private: const char * const * _arguments; diff --git a/src/core/FileEnumerator.h b/src/core/FileEnumerator.h index d39b237c14..1c854acb35 100644 --- a/src/core/FileEnumerator.h +++ b/src/core/FileEnumerator.h @@ -20,7 +20,7 @@ #include "../common.h" struct file_info; -class FileEnumerator +class FileEnumerator final { private: struct DirectoryState diff --git a/src/core/FileStream.hpp b/src/core/FileStream.hpp index 4716222a79..f632199f7f 100644 --- a/src/core/FileStream.hpp +++ b/src/core/FileStream.hpp @@ -30,7 +30,7 @@ enum /** * A stream for reading and writing to files. Wraps an SDL_RWops, SDL2's cross platform file stream. */ -class FileStream : public IStream +class FileStream final : public IStream { private: SDL_RWops * _file; diff --git a/src/core/Json.hpp b/src/core/Json.hpp index 4bf7bd8713..95ce1b6f62 100644 --- a/src/core/Json.hpp +++ b/src/core/Json.hpp @@ -30,7 +30,7 @@ namespace Json void WriteToFile(const utf8 * path, const json_t * json, size_t flags = 0); } -class JsonException : public Exception +class JsonException final : public Exception { private: json_error_t _jsonError = { 0 }; diff --git a/src/core/MemoryStream.h b/src/core/MemoryStream.h index 762944075b..012885c9fc 100644 --- a/src/core/MemoryStream.h +++ b/src/core/MemoryStream.h @@ -29,7 +29,7 @@ enum MEMORY_ACCESS /** * A stream for reading and writing to files. Wraps an SDL_RWops, SDL2's cross platform file stream. */ -class MemoryStream : public IStream +class MemoryStream final : public IStream { private: uint16 _access; diff --git a/src/core/Stopwatch.hpp b/src/core/Stopwatch.hpp index ea42fa2db3..1949e2b914 100644 --- a/src/core/Stopwatch.hpp +++ b/src/core/Stopwatch.hpp @@ -24,7 +24,7 @@ extern "C" /** * Class to accuately measure elapsed time with high precision. */ -class Stopwatch +class Stopwatch final { private: /** Number of ticks in a second. */ diff --git a/src/drawing/engines/SoftwareDrawingEngine.cpp b/src/drawing/engines/SoftwareDrawingEngine.cpp index 8f8e0eca70..be3a2114ab 100644 --- a/src/drawing/engines/SoftwareDrawingEngine.cpp +++ b/src/drawing/engines/SoftwareDrawingEngine.cpp @@ -45,7 +45,7 @@ struct DirtyGrid uint8 * Blocks; }; -class RainDrawer : public IRainDrawer +class RainDrawer final : public IRainDrawer { private: struct RainPixel @@ -156,7 +156,7 @@ public: } }; -class SoftwareDrawingContext : public IDrawingContext +class SoftwareDrawingContext final : public IDrawingContext { private: SoftwareDrawingEngine * _engine; @@ -179,7 +179,7 @@ public: void SetDPI(rct_drawpixelinfo * dpi); }; -class SoftwareDrawingEngine : public IDrawingEngine +class SoftwareDrawingEngine final : public IDrawingEngine { private: bool _hardwareDisplay; diff --git a/src/drawing/engines/opengl/CopyFramebufferShader.h b/src/drawing/engines/opengl/CopyFramebufferShader.h index 2ba4cb3887..d1757b4bc4 100644 --- a/src/drawing/engines/opengl/CopyFramebufferShader.h +++ b/src/drawing/engines/opengl/CopyFramebufferShader.h @@ -19,7 +19,7 @@ #include "GLSLTypes.h" #include "OpenGLShaderProgram.h" -class CopyFramebufferShader : public OpenGLShaderProgram +class CopyFramebufferShader final : public OpenGLShaderProgram { private: GLuint uScreenSize; diff --git a/src/drawing/engines/opengl/DrawImageShader.h b/src/drawing/engines/opengl/DrawImageShader.h index 5444232f88..89b0eebea6 100644 --- a/src/drawing/engines/opengl/DrawImageShader.h +++ b/src/drawing/engines/opengl/DrawImageShader.h @@ -36,7 +36,7 @@ struct DrawImageInstance { int mask; }; -class DrawImageShader : public OpenGLShaderProgram +class DrawImageShader final : public OpenGLShaderProgram { private: GLuint uScreenSize; diff --git a/src/drawing/engines/opengl/DrawLineShader.h b/src/drawing/engines/opengl/DrawLineShader.h index f8473b8dd9..38c68a05e0 100644 --- a/src/drawing/engines/opengl/DrawLineShader.h +++ b/src/drawing/engines/opengl/DrawLineShader.h @@ -19,7 +19,7 @@ #include "GLSLTypes.h" #include "OpenGLShaderProgram.h" -class DrawLineShader : public OpenGLShaderProgram +class DrawLineShader final : public OpenGLShaderProgram { private: GLuint uScreenSize; diff --git a/src/drawing/engines/opengl/FillRectShader.h b/src/drawing/engines/opengl/FillRectShader.h index 80af878fc6..63ba37a6be 100644 --- a/src/drawing/engines/opengl/FillRectShader.h +++ b/src/drawing/engines/opengl/FillRectShader.h @@ -21,7 +21,7 @@ class OpenGLFramebuffer; -class FillRectShader : public OpenGLShaderProgram +class FillRectShader final : public OpenGLShaderProgram { private: GLuint uScreenSize; diff --git a/src/drawing/engines/opengl/SwapFramebuffer.h b/src/drawing/engines/opengl/SwapFramebuffer.h index 68b638cd53..1ef93199cf 100644 --- a/src/drawing/engines/opengl/SwapFramebuffer.h +++ b/src/drawing/engines/opengl/SwapFramebuffer.h @@ -30,7 +30,7 @@ class OpenGLFramebuffer; * When you need to bind the current frame to a shader, call SwapCopy and * then bind the value of GetSourceTexture to your shader. */ -class SwapFramebuffer +class SwapFramebuffer final { private: sint32 _width; diff --git a/src/drawing/engines/opengl/TextureCache.h b/src/drawing/engines/opengl/TextureCache.h index 3092b0aa1f..36009222a7 100644 --- a/src/drawing/engines/opengl/TextureCache.h +++ b/src/drawing/engines/opengl/TextureCache.h @@ -73,7 +73,7 @@ struct CachedTextureInfo // Represents a texture atlas that images of a given maximum size can be allocated from // Atlases are all stored in the same 2D texture array, occupying the specified index // Slots in atlases are always squares. -class Atlas +class Atlas final { private: GLuint _index; @@ -183,7 +183,7 @@ private: } }; -class TextureCache +class TextureCache final { private: bool _atlasesTextureInitialised = false; diff --git a/src/localisation/LanguagePack.cpp b/src/localisation/LanguagePack.cpp index bb8b80c756..cca1e50662 100644 --- a/src/localisation/LanguagePack.cpp +++ b/src/localisation/LanguagePack.cpp @@ -61,7 +61,7 @@ struct ScenarioOverride }; }; -class LanguagePack : public ILanguagePack +class LanguagePack final : public ILanguagePack { private: uint16 _id; diff --git a/src/network/NetworkAction.h b/src/network/NetworkAction.h index 5c511fd322..cd5f65541c 100644 --- a/src/network/NetworkAction.h +++ b/src/network/NetworkAction.h @@ -20,7 +20,7 @@ #include #include "../common.h" -class NetworkAction +class NetworkAction final { public: rct_string_id Name; @@ -28,7 +28,7 @@ public: std::vector Commands; }; -class NetworkActions +class NetworkActions final { public: static const std::vector Actions; diff --git a/src/network/NetworkConnection.h b/src/network/NetworkConnection.h index 1e5bb56a11..0c49b1c0bb 100644 --- a/src/network/NetworkConnection.h +++ b/src/network/NetworkConnection.h @@ -29,7 +29,7 @@ class NetworkPlayer; -class NetworkConnection +class NetworkConnection final { public: ITcpSocket * Socket = nullptr; diff --git a/src/network/NetworkGroup.h b/src/network/NetworkGroup.h index 8d3b188abe..aec1795bd8 100644 --- a/src/network/NetworkGroup.h +++ b/src/network/NetworkGroup.h @@ -21,7 +21,7 @@ #include "NetworkPacket.h" #include "../common.h" -class NetworkGroup +class NetworkGroup final { public: std::array ActionsAllowed; diff --git a/src/network/NetworkKey.h b/src/network/NetworkKey.h index e9e0d97fe0..1ccd305778 100644 --- a/src/network/NetworkKey.h +++ b/src/network/NetworkKey.h @@ -27,7 +27,7 @@ typedef struct evp_pkey_st EVP_PKEY; typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; -class NetworkKey +class NetworkKey final { public: NetworkKey(); diff --git a/src/network/NetworkPacket.h b/src/network/NetworkPacket.h index 3baf56e232..883a47e072 100644 --- a/src/network/NetworkPacket.h +++ b/src/network/NetworkPacket.h @@ -21,7 +21,7 @@ #include "NetworkTypes.h" #include "../common.h" -class NetworkPacket +class NetworkPacket final { public: uint16 size; diff --git a/src/network/NetworkPlayer.h b/src/network/NetworkPlayer.h index 35afa2423d..bb4dba194f 100644 --- a/src/network/NetworkPlayer.h +++ b/src/network/NetworkPlayer.h @@ -26,7 +26,7 @@ extern "C" class NetworkPacket; -class NetworkPlayer +class NetworkPlayer final { public: uint8 id = 0; diff --git a/src/network/NetworkUser.h b/src/network/NetworkUser.h index 6dcbe33ed4..0c31341b03 100644 --- a/src/network/NetworkUser.h +++ b/src/network/NetworkUser.h @@ -23,7 +23,7 @@ #include #include -class NetworkUser +class NetworkUser final { public: std::string Hash; @@ -37,7 +37,7 @@ public: json_t * ToJson(json_t * json) const; }; -class NetworkUserManager +class NetworkUserManager final { public: ~NetworkUserManager(); diff --git a/src/object/BannerObject.h b/src/object/BannerObject.h index aebac64ae0..256075dad8 100644 --- a/src/object/BannerObject.h +++ b/src/object/BannerObject.h @@ -23,13 +23,13 @@ extern "C" #include "../world/scenery.h" } -class BannerObject : public SceneryObject +class BannerObject final : public SceneryObject { private: rct_scenery_entry _legacyType = { 0 }; public: - explicit BannerObject(const rct_object_entry &entry) : SceneryObject(entry) { }; + explicit BannerObject(const rct_object_entry &entry) : SceneryObject(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/EntranceObject.h b/src/object/EntranceObject.h index 93e2d7763d..8f35e4a55d 100644 --- a/src/object/EntranceObject.h +++ b/src/object/EntranceObject.h @@ -23,13 +23,13 @@ extern "C" #include "../world/entrance.h" } -class EntranceObject : public Object +class EntranceObject final : public Object { private: rct_entrance_type _legacyType = { 0 }; public: - explicit EntranceObject(const rct_object_entry &entry) : Object(entry) { }; + explicit EntranceObject(const rct_object_entry &entry) : Object(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/FootpathItemObject.h b/src/object/FootpathItemObject.h index 889a309825..6cbf7834e1 100644 --- a/src/object/FootpathItemObject.h +++ b/src/object/FootpathItemObject.h @@ -23,13 +23,13 @@ extern "C" #include "../world/scenery.h" } -class FootpathItemObject : public SceneryObject +class FootpathItemObject final : public SceneryObject { private: rct_scenery_entry _legacyType = { 0 }; public: - explicit FootpathItemObject(const rct_object_entry &entry) : SceneryObject(entry) { }; + explicit FootpathItemObject(const rct_object_entry &entry) : SceneryObject(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/FootpathObject.h b/src/object/FootpathObject.h index 327a061538..913e75fda7 100644 --- a/src/object/FootpathObject.h +++ b/src/object/FootpathObject.h @@ -23,13 +23,13 @@ extern "C" #include "../world/footpath.h" } -class FootpathObject : public Object +class FootpathObject final : public Object { private: rct_footpath_entry _legacyType = { 0 }; public: - explicit FootpathObject(const rct_object_entry &entry) : Object(entry) { }; + explicit FootpathObject(const rct_object_entry &entry) : Object(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/ImageTable.h b/src/object/ImageTable.h index a124344d86..80f549d06f 100644 --- a/src/object/ImageTable.h +++ b/src/object/ImageTable.h @@ -39,5 +39,5 @@ public: void Read(IReadObjectContext * context, IStream * stream); const rct_g1_element * GetImages() const { return _entries.data(); } - uint32 GetCount() const { return (uint32)_entries.size(); }; -}; \ No newline at end of file + uint32 GetCount() const { return (uint32)_entries.size(); } +}; diff --git a/src/object/LargeSceneryObject.h b/src/object/LargeSceneryObject.h index ebe3a4c3a9..9a8420d5b6 100644 --- a/src/object/LargeSceneryObject.h +++ b/src/object/LargeSceneryObject.h @@ -23,7 +23,7 @@ extern "C" #include "../world/scenery.h" } -class LargeSceneryObject : public SceneryObject +class LargeSceneryObject final : public SceneryObject { private: rct_scenery_entry _legacyType = { 0 }; @@ -32,7 +32,7 @@ private: rct_large_scenery_tile * _tiles = nullptr; public: - explicit LargeSceneryObject(const rct_object_entry &entry) : SceneryObject(entry) { }; + explicit LargeSceneryObject(const rct_object_entry &entry) : SceneryObject(entry) { } ~LargeSceneryObject(); void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/RideObject.h b/src/object/RideObject.h index 0a152ea301..a3994942fa 100644 --- a/src/object/RideObject.h +++ b/src/object/RideObject.h @@ -23,7 +23,7 @@ extern "C" #include "../ride/ride.h" } -class RideObject : public Object +class RideObject final : public Object { private: rct_ride_entry _legacyType = { 0 }; @@ -31,7 +31,7 @@ private: sint8 * _peepLoadingPositions[4] = { nullptr }; public: - explicit RideObject(const rct_object_entry &entry) : Object(entry) { }; + explicit RideObject(const rct_object_entry &entry) : Object(entry) { } ~RideObject(); void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/SceneryGroupObject.h b/src/object/SceneryGroupObject.h index 03b0697a8a..0b59597021 100644 --- a/src/object/SceneryGroupObject.h +++ b/src/object/SceneryGroupObject.h @@ -25,7 +25,7 @@ extern "C" struct ObjectRepositoryItem; -class SceneryGroupObject : public Object +class SceneryGroupObject final : public Object { private: rct_scenery_set_entry _legacyType = { 0 }; @@ -33,7 +33,7 @@ private: rct_object_entry * _items = nullptr; public: - explicit SceneryGroupObject(const rct_object_entry &entry) : Object(entry) { }; + explicit SceneryGroupObject(const rct_object_entry &entry) : Object(entry) { } ~SceneryGroupObject(); void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/SmallSceneryObject.h b/src/object/SmallSceneryObject.h index a7f77b5e8b..4bb2670697 100644 --- a/src/object/SmallSceneryObject.h +++ b/src/object/SmallSceneryObject.h @@ -23,14 +23,14 @@ extern "C" #include "../world/scenery.h" } -class SmallSceneryObject : public SceneryObject +class SmallSceneryObject final : public SceneryObject { private: rct_scenery_entry _legacyType = { 0 }; uint8 * _var10data = nullptr; public: - explicit SmallSceneryObject(const rct_object_entry &entry) : SceneryObject(entry) { }; + explicit SmallSceneryObject(const rct_object_entry &entry) : SceneryObject(entry) { } ~SmallSceneryObject(); void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/StexObject.h b/src/object/StexObject.h index b922951b63..b4865d06c3 100644 --- a/src/object/StexObject.h +++ b/src/object/StexObject.h @@ -23,13 +23,13 @@ extern "C" #include "../scenario.h" } -class StexObject : public Object +class StexObject final : public Object { private: rct_stex_entry _legacyType = { 0 }; public: - explicit StexObject(const rct_object_entry &entry) : Object(entry) { }; + explicit StexObject(const rct_object_entry &entry) : Object(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/WallObject.h b/src/object/WallObject.h index 3b3f44b95d..c4dbe1eefb 100644 --- a/src/object/WallObject.h +++ b/src/object/WallObject.h @@ -23,13 +23,13 @@ extern "C" #include "../world/scenery.h" } -class WallObject : public SceneryObject +class WallObject final : public SceneryObject { private: rct_scenery_entry _legacyType = { 0 }; public: - explicit WallObject(const rct_object_entry &entry) : SceneryObject(entry) { }; + explicit WallObject(const rct_object_entry &entry) : SceneryObject(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/object/WaterObject.h b/src/object/WaterObject.h index 1c946d0372..816a194379 100644 --- a/src/object/WaterObject.h +++ b/src/object/WaterObject.h @@ -23,13 +23,13 @@ extern "C" #include "../world/water.h" } -class WaterObject : public Object +class WaterObject final : public Object { private: rct_water_type _legacyType = { 0 }; public: - explicit WaterObject(const rct_object_entry &entry) : Object(entry) { }; + explicit WaterObject(const rct_object_entry &entry) : Object(entry) { } void * GetLegacyData() override { return &_legacyType; } diff --git a/src/rct2/S6Exporter.h b/src/rct2/S6Exporter.h index e8c356b483..9cba306ddf 100644 --- a/src/rct2/S6Exporter.h +++ b/src/rct2/S6Exporter.h @@ -27,7 +27,7 @@ extern "C" /** * Class to export RollerCoaster Tycoon 2 scenarios (*.SC6) and saved games (*.SV6). */ -class S6Exporter +class S6Exporter final { public: bool ExportObjects; diff --git a/src/rct2/S6Importer.h b/src/rct2/S6Importer.h index 8b2fa9e37a..d23ad1e0dd 100644 --- a/src/rct2/S6Importer.h +++ b/src/rct2/S6Importer.h @@ -26,7 +26,7 @@ extern "C" /** * Class to import RollerCoaster Tycoon 2 scenarios (*.SC6) and saved games (*.SV6). */ -class S6Importer +class S6Importer final { public: bool FixIssues;