From dea69b229c6e4de5f0b3b37149dc40f06b538246 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 29 Aug 2025 00:00:39 +0200 Subject: [PATCH] Remove small translation units Remove .cpp files with small amount of code which don't have additional includes compared to corresponding .hpp files. This reduces the total size of preprocessed code of the project and should reduce compilation time. --- apps/essimporter/CMakeLists.txt | 1 - apps/essimporter/importercontext.cpp | 0 apps/opencs/CMakeLists.txt | 20 +++++++++++------- apps/opencs/model/filter/booleannode.cpp | 21 ------------------- apps/opencs/model/filter/booleannode.hpp | 12 ++++++++--- apps/opencs/model/filter/leafnode.cpp | 6 ------ apps/opencs/model/filter/leafnode.hpp | 2 +- apps/opencs/model/world/cell.cpp | 10 --------- apps/opencs/model/world/cell.hpp | 9 +++++--- .../opencs/model/world/nestedtablewrapper.cpp | 6 ------ .../opencs/model/world/nestedtablewrapper.hpp | 2 +- apps/opencs/model/world/record.cpp | 16 -------------- apps/opencs/model/world/record.hpp | 6 +++--- apps/opencs/view/doc/sizehint.cpp | 16 -------------- apps/opencs/view/doc/sizehint.hpp | 10 ++++++--- apps/opencs/view/render/tagbase.cpp | 18 ---------------- apps/opencs/view/render/tagbase.hpp | 9 +++++--- apps/openmw/mwscript/consoleextensions.cpp | 11 ---------- apps/openmw/mwscript/consoleextensions.hpp | 2 +- components/compiler/nullerrorhandler.cpp | 5 ----- components/compiler/nullerrorhandler.hpp | 4 ++-- components/compiler/opcodes.cpp | 7 ------- components/compiler/opcodes.hpp | 10 ++++++++- components/esm/common.cpp | 16 -------------- components/esm/common.hpp | 11 +++++++++- components/esm3/containerstate.cpp | 20 ------------------ components/esm3/containerstate.hpp | 15 +++++++++++-- components/files/constrainedfilestream.cpp | 12 ----------- components/files/constrainedfilestream.hpp | 11 ++++++---- components/lua_ui/alignment.cpp | 18 ---------------- components/lua_ui/alignment.hpp | 16 ++++++++++++-- 31 files changed, 101 insertions(+), 221 deletions(-) delete mode 100644 apps/essimporter/importercontext.cpp delete mode 100644 apps/opencs/model/filter/booleannode.cpp delete mode 100644 apps/opencs/model/filter/leafnode.cpp delete mode 100644 apps/opencs/model/world/cell.cpp delete mode 100644 apps/opencs/model/world/nestedtablewrapper.cpp delete mode 100644 apps/opencs/model/world/record.cpp delete mode 100644 apps/opencs/view/doc/sizehint.cpp delete mode 100644 apps/opencs/view/render/tagbase.cpp delete mode 100644 apps/openmw/mwscript/consoleextensions.cpp delete mode 100644 components/compiler/nullerrorhandler.cpp delete mode 100644 components/compiler/opcodes.cpp delete mode 100644 components/esm/common.cpp delete mode 100644 components/esm3/containerstate.cpp delete mode 100644 components/files/constrainedfilestream.cpp delete mode 100644 components/lua_ui/alignment.cpp diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt index 217d3e7b50..d53b48cf96 100644 --- a/apps/essimporter/CMakeLists.txt +++ b/apps/essimporter/CMakeLists.txt @@ -17,7 +17,6 @@ set(ESSIMPORTER_FILES importscpt.cpp importproj.cpp importsplm.cpp - importercontext.cpp converter.cpp convertacdt.cpp convertnpcc.cpp diff --git a/apps/essimporter/importercontext.cpp b/apps/essimporter/importercontext.cpp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index c9ca7838be..35838970ff 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -23,14 +23,14 @@ opencs_units (model/world opencs_units (model/world - universalid record commands columnbase columnimp scriptcontext cell refidcollection + universalid commands columnbase columnimp scriptcontext refidcollection refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope - pathgrid land nestedtablewrapper nestedcollection nestedcoladapterimp nestedinfocollection + pathgrid land nestedcollection nestedcoladapterimp nestedinfocollection idcompletionmanager metadata defaultgmsts infoselectwrapper commandmacro ) opencs_hdrs (model/world - columnimp disabletag idcollection collection info subcellcollection + columnimp disabletag idcollection collection info subcellcollection cell nestedtablewrapper record ) @@ -52,7 +52,7 @@ opencs_hdrs (model/tools opencs_units (view/doc viewmanager view operations operation subview startup filedialog newgame - filewidget adjusterwidget loader globaldebugprofilemenu runlogsubview sizehint + filewidget adjusterwidget loader globaldebugprofilemenu runlogsubview ) @@ -61,7 +61,7 @@ opencs_units (view/doc ) opencs_hdrs (view/doc - subviewfactoryimp + subviewfactoryimp sizehint ) @@ -92,12 +92,12 @@ opencs_units (view/render ) opencs_units (view/render - lighting lightingday lightingnight lightingbright object cell terrainstorage tagbase + lighting lightingday lightingnight lightingbright object cell terrainstorage cellarrow cellmarker cellborder pathgrid ) opencs_hdrs (view/render - mask + mask tagbase ) @@ -123,7 +123,11 @@ opencs_units (model/prefs ) opencs_units (model/filter - unarynode narynode leafnode booleannode parser andnode ornode notnode textnode valuenode + unarynode narynode parser andnode ornode notnode textnode valuenode + ) + +opencs_hdrs (model/filter + leafnode booleannode ) opencs_units (view/filter diff --git a/apps/opencs/model/filter/booleannode.cpp b/apps/opencs/model/filter/booleannode.cpp deleted file mode 100644 index 7f93b0b3b5..0000000000 --- a/apps/opencs/model/filter/booleannode.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "booleannode.hpp" - -namespace CSMWorld -{ - class IdTableBase; -} - -CSMFilter::BooleanNode::BooleanNode(bool value) - : mTrue(value) -{ -} - -bool CSMFilter::BooleanNode::test(const CSMWorld::IdTableBase& table, int row, const std::map& columns) const -{ - return mTrue; -} - -std::string CSMFilter::BooleanNode::toString(bool numericColumns) const -{ - return mTrue ? "true" : "false"; -} diff --git a/apps/opencs/model/filter/booleannode.hpp b/apps/opencs/model/filter/booleannode.hpp index 275cbf4e55..add06caa70 100644 --- a/apps/opencs/model/filter/booleannode.hpp +++ b/apps/opencs/model/filter/booleannode.hpp @@ -18,13 +18,19 @@ namespace CSMFilter bool mTrue; public: - explicit BooleanNode(bool value); + explicit BooleanNode(bool value) + : mTrue(value) + { + } - bool test(const CSMWorld::IdTableBase& table, int row, const std::map& columns) const override; + bool test(const CSMWorld::IdTableBase& table, int row, const std::map& columns) const override + { + return mTrue; + } ///< \return Can the specified table row pass through to filter? /// \param columns column ID to column index mapping - std::string toString(bool numericColumns) const override; + std::string toString(bool numericColumns) const override { return mTrue ? "true" : "false"; } ///< Return a string that represents this node. /// /// \param numericColumns Use numeric IDs instead of string to represent columns. diff --git a/apps/opencs/model/filter/leafnode.cpp b/apps/opencs/model/filter/leafnode.cpp deleted file mode 100644 index fd37c6cb64..0000000000 --- a/apps/opencs/model/filter/leafnode.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "leafnode.hpp" - -std::vector CSMFilter::LeafNode::getReferencedColumns() const -{ - return std::vector(); -} diff --git a/apps/opencs/model/filter/leafnode.hpp b/apps/opencs/model/filter/leafnode.hpp index bf90da18b0..0109304801 100644 --- a/apps/opencs/model/filter/leafnode.hpp +++ b/apps/opencs/model/filter/leafnode.hpp @@ -10,7 +10,7 @@ namespace CSMFilter class LeafNode : public Node { public: - std::vector getReferencedColumns() const override; + std::vector getReferencedColumns() const override { return {}; } ///< Return a list of the IDs of the columns referenced by this node. The column mapping /// passed into test as columns must contain all columns listed here. }; diff --git a/apps/opencs/model/world/cell.cpp b/apps/opencs/model/world/cell.cpp deleted file mode 100644 index edf3b0d40c..0000000000 --- a/apps/opencs/model/world/cell.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "cell.hpp" - -#include - -void CSMWorld::Cell::load(ESM::ESMReader& esm, bool& isDeleted) -{ - ESM::Cell::load(esm, isDeleted, false); - - mId = ESM::RefId::stringRefId(ESM::Cell::mId.toString()); -} diff --git a/apps/opencs/model/world/cell.hpp b/apps/opencs/model/world/cell.hpp index 5d4aefbda2..7e656859a5 100644 --- a/apps/opencs/model/world/cell.hpp +++ b/apps/opencs/model/world/cell.hpp @@ -1,8 +1,6 @@ #ifndef CSM_WOLRD_CELL_H #define CSM_WOLRD_CELL_H -#include - #include namespace ESM @@ -20,7 +18,12 @@ namespace CSMWorld { ESM::RefId mId; - void load(ESM::ESMReader& esm, bool& isDeleted); + void load(ESM::ESMReader& esm, bool& isDeleted) + { + ESM::Cell::load(esm, isDeleted, false); + + mId = ESM::RefId::stringRefId(ESM::Cell::mId.toString()); + } }; } diff --git a/apps/opencs/model/world/nestedtablewrapper.cpp b/apps/opencs/model/world/nestedtablewrapper.cpp deleted file mode 100644 index 0060276201..0000000000 --- a/apps/opencs/model/world/nestedtablewrapper.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "nestedtablewrapper.hpp" - -int CSMWorld::NestedTableWrapperBase::size() const -{ - return -5; -} diff --git a/apps/opencs/model/world/nestedtablewrapper.hpp b/apps/opencs/model/world/nestedtablewrapper.hpp index 4756409c96..69a00bf9c7 100644 --- a/apps/opencs/model/world/nestedtablewrapper.hpp +++ b/apps/opencs/model/world/nestedtablewrapper.hpp @@ -7,7 +7,7 @@ namespace CSMWorld { virtual ~NestedTableWrapperBase() = default; - virtual int size() const; + virtual int size() const { return -5; } NestedTableWrapperBase() = default; }; diff --git a/apps/opencs/model/world/record.cpp b/apps/opencs/model/world/record.cpp deleted file mode 100644 index ddd9050828..0000000000 --- a/apps/opencs/model/world/record.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "record.hpp" - -bool CSMWorld::RecordBase::isDeleted() const -{ - return mState == State_Deleted || mState == State_Erased; -} - -bool CSMWorld::RecordBase::isErased() const -{ - return mState == State_Erased; -} - -bool CSMWorld::RecordBase::isModified() const -{ - return mState == State_Modified || mState == State_ModifiedOnly; -} \ No newline at end of file diff --git a/apps/opencs/model/world/record.hpp b/apps/opencs/model/world/record.hpp index 35e4c82a35..29ac589bea 100644 --- a/apps/opencs/model/world/record.hpp +++ b/apps/opencs/model/world/record.hpp @@ -33,11 +33,11 @@ namespace CSMWorld virtual void assign(const RecordBase& record) = 0; ///< Will throw an exception if the types don't match. - bool isDeleted() const; + bool isDeleted() const { return mState == State_Deleted || mState == State_Erased; } - bool isErased() const; + bool isErased() const { return mState == State_Erased; } - bool isModified() const; + bool isModified() const { return mState == State_Modified || mState == State_ModifiedOnly; } }; template diff --git a/apps/opencs/view/doc/sizehint.cpp b/apps/opencs/view/doc/sizehint.cpp deleted file mode 100644 index 8b907ead09..0000000000 --- a/apps/opencs/view/doc/sizehint.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sizehint.hpp" - -CSVDoc::SizeHintWidget::SizeHintWidget(QWidget* parent) - : QWidget(parent) -{ -} - -QSize CSVDoc::SizeHintWidget::sizeHint() const -{ - return mSize; -} - -void CSVDoc::SizeHintWidget::setSizeHint(const QSize& size) -{ - mSize = size; -} diff --git a/apps/opencs/view/doc/sizehint.hpp b/apps/opencs/view/doc/sizehint.hpp index a0296a51ec..66ae962e0a 100644 --- a/apps/opencs/view/doc/sizehint.hpp +++ b/apps/opencs/view/doc/sizehint.hpp @@ -11,11 +11,15 @@ namespace CSVDoc QSize mSize; public: - SizeHintWidget(QWidget* parent = nullptr); + explicit SizeHintWidget(QWidget* parent = nullptr) + : QWidget(parent) + { + } + ~SizeHintWidget() override = default; - QSize sizeHint() const override; - void setSizeHint(const QSize& size); + QSize sizeHint() const override { return mSize; } + void setSizeHint(const QSize& size) { mSize = size; } }; } diff --git a/apps/opencs/view/render/tagbase.cpp b/apps/opencs/view/render/tagbase.cpp deleted file mode 100644 index b52a553c97..0000000000 --- a/apps/opencs/view/render/tagbase.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "tagbase.hpp" - -#include - -CSVRender::TagBase::TagBase(Mask mask) - : mMask(mask) -{ -} - -CSVRender::Mask CSVRender::TagBase::getMask() const -{ - return mMask; -} - -QString CSVRender::TagBase::getToolTip(bool hideBasics, const WorldspaceHitResult& /*hit*/) const -{ - return ""; -} diff --git a/apps/opencs/view/render/tagbase.hpp b/apps/opencs/view/render/tagbase.hpp index a93267b6f4..6e6ee5b9a9 100644 --- a/apps/opencs/view/render/tagbase.hpp +++ b/apps/opencs/view/render/tagbase.hpp @@ -16,11 +16,14 @@ namespace CSVRender Mask mMask; public: - TagBase(Mask mask); + explicit TagBase(Mask mask) + : mMask(mask) + { + } - Mask getMask() const; + Mask getMask() const { return mMask; } - virtual QString getToolTip(bool hideBasics, const WorldspaceHitResult& hit) const; + virtual QString getToolTip(bool hideBasics, const WorldspaceHitResult& hit) const { return {}; } }; } diff --git a/apps/openmw/mwscript/consoleextensions.cpp b/apps/openmw/mwscript/consoleextensions.cpp deleted file mode 100644 index 08a13e43ac..0000000000 --- a/apps/openmw/mwscript/consoleextensions.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "consoleextensions.hpp" - -#include - -namespace MWScript -{ - namespace Console - { - void installOpcodes(Interpreter::Interpreter& interpreter) {} - } -} diff --git a/apps/openmw/mwscript/consoleextensions.hpp b/apps/openmw/mwscript/consoleextensions.hpp index 828557271a..5586323719 100644 --- a/apps/openmw/mwscript/consoleextensions.hpp +++ b/apps/openmw/mwscript/consoleextensions.hpp @@ -16,7 +16,7 @@ namespace MWScript /// \brief Script functionality limited to the console namespace Console { - void installOpcodes(Interpreter::Interpreter& interpreter); + void installOpcodes(Interpreter::Interpreter& interpreter) {} } } diff --git a/components/compiler/nullerrorhandler.cpp b/components/compiler/nullerrorhandler.cpp deleted file mode 100644 index 96735366eb..0000000000 --- a/components/compiler/nullerrorhandler.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "nullerrorhandler.hpp" - -void Compiler::NullErrorHandler::report(const std::string& message, const TokenLoc& loc, Type type) {} - -void Compiler::NullErrorHandler::report(const std::string& message, Type type) {} diff --git a/components/compiler/nullerrorhandler.hpp b/components/compiler/nullerrorhandler.hpp index 7f2e086699..5d70ddd31a 100644 --- a/components/compiler/nullerrorhandler.hpp +++ b/components/compiler/nullerrorhandler.hpp @@ -9,10 +9,10 @@ namespace Compiler class NullErrorHandler : public ErrorHandler { - void report(const std::string& message, const TokenLoc& loc, Type type) override; + void report(const std::string& message, const TokenLoc& loc, Type type) override {} ///< Report error to the user. - void report(const std::string& message, Type type) override; + void report(const std::string& message, Type type) override {} ///< Report a file related error }; } diff --git a/components/compiler/opcodes.cpp b/components/compiler/opcodes.cpp deleted file mode 100644 index eb57e28fd4..0000000000 --- a/components/compiler/opcodes.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "opcodes.hpp" - -namespace Compiler::Control -{ - const char* controls[numberOfControls] = { "playercontrols", "playerfighting", "playerjumping", "playerlooking", - "playermagic", "playerviewswitch", "vanitymode" }; -} diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index 55f431f049..c0aab2f08c 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -115,7 +115,15 @@ namespace Compiler { const int numberOfControls = 7; - extern const char* controls[numberOfControls]; + inline constexpr const char* controls[numberOfControls] = { + "playercontrols", + "playerfighting", + "playerjumping", + "playerlooking", + "playermagic", + "playerviewswitch", + "vanitymode", + }; const int opcodeEnable = 0x200007e; const int opcodeDisable = 0x2000085; diff --git a/components/esm/common.cpp b/components/esm/common.cpp deleted file mode 100644 index cde084f039..0000000000 --- a/components/esm/common.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -namespace ESM -{ - std::string printName(const std::uint32_t typeId) - { - unsigned char typeName[4]; - typeName[0] = typeId & 0xff; - typeName[1] = (typeId >> 8) & 0xff; - typeName[2] = (typeId >> 16) & 0xff; - typeName[3] = (typeId >> 24) & 0xff; - - return std::string((char*)typeName, 4); - } -} diff --git a/components/esm/common.hpp b/components/esm/common.hpp index 7d149a865c..76b06dd58b 100644 --- a/components/esm/common.hpp +++ b/components/esm/common.hpp @@ -42,7 +42,16 @@ namespace ESM std::uint64_t size; }; - std::string printName(const std::uint32_t typeId); + inline std::string printName(const std::uint32_t typeId) + { + unsigned char typeName[4]; + typeName[0] = typeId & 0xff; + typeName[1] = (typeId >> 8) & 0xff; + typeName[2] = (typeId >> 16) & 0xff; + typeName[3] = (typeId >> 24) & 0xff; + + return std::string(reinterpret_cast(typeName), 4); + } } #endif // COMPONENT_ESM_COMMON_H diff --git a/components/esm3/containerstate.cpp b/components/esm3/containerstate.cpp deleted file mode 100644 index 63d21e24bd..0000000000 --- a/components/esm3/containerstate.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "containerstate.hpp" - -namespace ESM -{ - - void ContainerState::load(ESMReader& esm) - { - ObjectState::load(esm); - - mInventory.load(esm); - } - - void ContainerState::save(ESMWriter& esm, bool inInventory) const - { - ObjectState::save(esm, inInventory); - - mInventory.save(esm); - } - -} diff --git a/components/esm3/containerstate.hpp b/components/esm3/containerstate.hpp index 55a19ffc15..1da420beca 100644 --- a/components/esm3/containerstate.hpp +++ b/components/esm3/containerstate.hpp @@ -12,8 +12,19 @@ namespace ESM { InventoryState mInventory; - void load(ESMReader& esm) override; - void save(ESMWriter& esm, bool inInventory = false) const override; + void load(ESMReader& esm) override + { + ObjectState::load(esm); + + mInventory.load(esm); + } + + void save(ESMWriter& esm, bool inInventory = false) const override + { + ObjectState::save(esm, inInventory); + + mInventory.save(esm); + } ContainerState& asContainerState() override { return *this; } const ContainerState& asContainerState() const override { return *this; } diff --git a/components/files/constrainedfilestream.cpp b/components/files/constrainedfilestream.cpp deleted file mode 100644 index a79a31a842..0000000000 --- a/components/files/constrainedfilestream.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include "constrainedfilestream.hpp" - -namespace Files -{ - IStreamPtr openConstrainedFileStream(const std::filesystem::path& filename, std::size_t start, std::size_t length) - { - return std::make_unique( - std::make_unique(filename, start, length)); - } -} diff --git a/components/files/constrainedfilestream.hpp b/components/files/constrainedfilestream.hpp index 941f0ee493..2c0290aadd 100644 --- a/components/files/constrainedfilestream.hpp +++ b/components/files/constrainedfilestream.hpp @@ -5,8 +5,8 @@ #include "istreamptr.hpp" #include "streamwithbuffer.hpp" +#include #include -#include namespace Files { @@ -14,9 +14,12 @@ namespace Files /// A file stream constrained to a specific region in the file, specified by the 'start' and 'length' parameters. using ConstrainedFileStream = StreamWithBuffer; - IStreamPtr openConstrainedFileStream(const std::filesystem::path& filename, std::size_t start = 0, - std::size_t length = std::numeric_limits::max()); - + inline IStreamPtr openConstrainedFileStream(const std::filesystem::path& filename, std::size_t start = 0, + std::size_t length = std::numeric_limits::max()) + { + return std::make_unique( + std::make_unique(filename, start, length)); + } } #endif diff --git a/components/lua_ui/alignment.cpp b/components/lua_ui/alignment.cpp deleted file mode 100644 index 358c5ba14b..0000000000 --- a/components/lua_ui/alignment.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "alignment.hpp" - -namespace LuaUi -{ - MyGUI::Align alignmentToMyGui(Alignment horizontal, Alignment vertical) - { - MyGUI::Align align(MyGUI::Align::Center); - if (horizontal == Alignment::Start) - align |= MyGUI::Align::Left; - if (horizontal == Alignment::End) - align |= MyGUI::Align::Right; - if (vertical == Alignment::Start) - align |= MyGUI::Align::Top; - if (vertical == Alignment::End) - align |= MyGUI::Align::Bottom; - return align; - } -} diff --git a/components/lua_ui/alignment.hpp b/components/lua_ui/alignment.hpp index 8503ffba03..b53ca04abc 100644 --- a/components/lua_ui/alignment.hpp +++ b/components/lua_ui/alignment.hpp @@ -12,7 +12,19 @@ namespace LuaUi End = 2 }; - MyGUI::Align alignmentToMyGui(Alignment horizontal, Alignment vertical); + inline MyGUI::Align alignmentToMyGui(Alignment horizontal, Alignment vertical) + { + MyGUI::Align align(MyGUI::Align::Center); + if (horizontal == Alignment::Start) + align |= MyGUI::Align::Left; + if (horizontal == Alignment::End) + align |= MyGUI::Align::Right; + if (vertical == Alignment::Start) + align |= MyGUI::Align::Top; + if (vertical == Alignment::End) + align |= MyGUI::Align::Bottom; + return align; + } } -#endif // !OPENMW_LUAUI_PROPERTIES +#endif