From fdf1c4a9ee029deced05dae8879363907d1908c4 Mon Sep 17 00:00:00 2001 From: prisixia Date: Fri, 5 May 2023 20:29:32 +0200 Subject: [PATCH] clang-tidy: modernize-pass-by-value --- include/error.h | 2 +- include/starbound/frames.h | 4 ++-- include/starbound/item.h | 12 +++++------- include/starbound/metadata.h | 10 +++++----- include/starpounds/species.h | 4 ++-- include/starpounds/weightstage.h | 14 ++++++-------- src/error.cpp | 4 ++-- src/starbound/frames.cpp | 9 ++++----- src/starbound/item.cpp | 33 ++++++++++++++++---------------- src/starbound/metadata.cpp | 15 ++++++++------- src/starpounds/species.cpp | 13 ++++++------- src/starpounds/weightstage.cpp | 32 +++++++++++++++---------------- 12 files changed, 74 insertions(+), 78 deletions(-) diff --git a/include/error.h b/include/error.h index bf499ad..3d15dca 100644 --- a/include/error.h +++ b/include/error.h @@ -37,7 +37,7 @@ along with speciesgen. If not, see . namespace SpeciesGen { class ErrorHandler { public: - ErrorHandler(const std::string & = "ErrorHandler"); + ErrorHandler(std::string = "ErrorHandler"); virtual size_t CheckForErrors() = 0; virtual std::string GetError(const size_t); virtual void ClearErrors(); diff --git a/include/starbound/frames.h b/include/starbound/frames.h index a5a721c..9a18968 100644 --- a/include/starbound/frames.h +++ b/include/starbound/frames.h @@ -44,7 +44,7 @@ namespace Starbound::Frames { class Grid { public: Grid() = delete; - Grid(const std::vector>> &, + Grid(std::vector>>, const std::tuple = {129, 129}, const std::tuple = {9, 6}); @@ -66,7 +66,7 @@ private: class Frames { public: Frames() = delete; - Frames(const std::unordered_map &, const Grid &); + Frames(std::unordered_map, Grid); [[nodiscard]] std::unordered_map GetAliases() const; diff --git a/include/starbound/item.h b/include/starbound/item.h index 8db6625..2249437 100644 --- a/include/starbound/item.h +++ b/include/starbound/item.h @@ -54,9 +54,8 @@ enum class TooltipKind { Armor = 0 }; class Frames { public: Frames() = default; - Frames(const std::filesystem::path &); - Frames(const std::filesystem::path &, const std::filesystem::path &, - const std::filesystem::path &); + Frames(std::filesystem::path); + Frames(std::filesystem::path, std::filesystem::path, std::filesystem::path); [[nodiscard]] std::filesystem::path GetBody() const; [[nodiscard]] std::filesystem::path GetBackSleeve() const; @@ -75,10 +74,9 @@ private: class Item { public: Item() = default; - Item(const std::string &, const Rarity); - Item(const std::string &, const std::filesystem::path &, const Category, - const std::string &, const std::string &, const Frames &, - const Frames &); + Item(std::string, const Rarity); + Item(std::string, std::filesystem::path, const Category, std::string, + std::string, Frames, Frames); [[nodiscard]] std::string GetItemName() const; [[nodiscard]] uint32_t GetPrice() const; diff --git a/include/starbound/metadata.h b/include/starbound/metadata.h index e848a9e..dbb618d 100644 --- a/include/starbound/metadata.h +++ b/include/starbound/metadata.h @@ -41,12 +41,12 @@ namespace Starbound { class Metadata { public: Metadata() = default; - Metadata(const std::string &, const std::string &, const std::string &, - const std::string & = + Metadata(std::string, std::string, std::string, + std::string = "This mod has been generated via speciesgen made by prisixia.", - const std::string & = "1.0.0_gen" SPECIESGEN_VERSION, - const std::string & = "http://git.vern.cc/prisixia/speciesgen", - const std::vector & = {"starpounds"}); + std::string = "1.0.0_gen" SPECIESGEN_VERSION, + std::string = "http://git.vern.cc/prisixia/speciesgen", + std::vector = {"starpounds"}); [[nodiscard]] std::string GetName() const; [[nodiscard]] std::string GetFriendlyName() const; diff --git a/include/starpounds/species.h b/include/starpounds/species.h index c6aab4e..34223a5 100644 --- a/include/starpounds/species.h +++ b/include/starpounds/species.h @@ -39,8 +39,8 @@ namespace Starpounds { class SpeciesConfig { public: SpeciesConfig(const bool = false); - SpeciesConfig(const std::string &, const bool = false); - SpeciesConfig(const std::string &, const std::string &, const bool = false); + SpeciesConfig(std::string, const bool = false); + SpeciesConfig(std::string, std::string, const bool = false); [[nodiscard]] bool GetFullbright() const; [[nodiscard]] std::string GetOverride() const; diff --git a/include/starpounds/weightstage.h b/include/starpounds/weightstage.h index 217fd5e..176c446 100644 --- a/include/starpounds/weightstage.h +++ b/include/starpounds/weightstage.h @@ -43,10 +43,9 @@ namespace Starpounds { class WeightStageSub { public: WeightStageSub() = default; - WeightStageSub(const std::string &, const std::string &, - const std::string &, const Types::Chests); - WeightStageSub(const std::string &); - WeightStageSub(const Types::Subs, const std::string &); + WeightStageSub(std::string, std::string, std::string, const Types::Chests); + WeightStageSub(std::string); + WeightStageSub(const Types::Subs, std::string); [[nodiscard]] std::string GetName() const; [[nodiscard]] std::string GetFriendlyName() const; @@ -69,11 +68,10 @@ class WeightStage : public WeightStageSub { public: WeightStage() = default; WeightStage(const std::string &, const std::string &, const std::string &, - const Types::Chests, const std::string &, const Types::Legs, - const bool, const bool, - const std::vector & = {}); + const Types::Chests, std::string, const Types::Legs, const bool, + const bool, std::vector = {}); WeightStage(const std::string &, const bool, const bool, - const std::vector & = {}); + std::vector = {}); [[nodiscard]] std::string GetLegDescription() const; [[nodiscard]] Types::Legs GetLegType() const; diff --git a/src/error.cpp b/src/error.cpp index 4dcec94..cfceb87 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -26,8 +26,8 @@ namespace SpeciesGen { // ErrorHandler //---------------------------------------------------------------------- -ErrorHandler::ErrorHandler(const std::string &handlerName) - : m_handlerName(handlerName) {} +ErrorHandler::ErrorHandler(std::string handlerName) + : m_handlerName(std::move(handlerName)) {} std::string ErrorHandler::GetError(const size_t index) { const std::string handlerName = m_handlerName; diff --git a/src/starbound/frames.cpp b/src/starbound/frames.cpp index de9e96d..4e2f4f5 100644 --- a/src/starbound/frames.cpp +++ b/src/starbound/frames.cpp @@ -26,10 +26,10 @@ namespace Starbound::Frames { // Grid //---------------------------------------------------------------------- -Grid::Grid(const std::vector>> &names, +Grid::Grid(std::vector>> names, const std::tuple size, const std::tuple dimensions) - : m_size(size), m_dimensions(dimensions), m_names(names) {} + : m_size(size), m_dimensions(dimensions), m_names(std::move(names)) {} std::tuple Grid::GetSize() const { return m_size; } @@ -56,9 +56,8 @@ void Grid::SetNames( // Frames //---------------------------------------------------------------------- -Frames::Frames(const std::unordered_map &aliases, - const Grid &grid) - : m_aliases(aliases), m_grid(grid) {} +Frames::Frames(std::unordered_map aliases, Grid grid) + : m_aliases(std::move(aliases)), m_grid(std::move(grid)) {} std::unordered_map Frames::GetAliases() const { return m_aliases; diff --git a/src/starbound/item.cpp b/src/starbound/item.cpp index 60b2b84..5cffb74 100644 --- a/src/starbound/item.cpp +++ b/src/starbound/item.cpp @@ -26,12 +26,12 @@ namespace Starbound::Item { // Frames //---------------------------------------------------------------------- -Frames::Frames(const std::filesystem::path &body) : m_body(body) {} +Frames::Frames(std::filesystem::path body) : m_body(std::move(body)) {} -Frames::Frames(const std::filesystem::path &body, - const std::filesystem::path &backSleeve, - const std::filesystem::path &frontSleeve) - : m_body(body), m_backSleeve(backSleeve), m_frontSleeve(frontSleeve) {} +Frames::Frames(std::filesystem::path body, std::filesystem::path backSleeve, + std::filesystem::path frontSleeve) + : m_body(std::move(body)), m_backSleeve(std::move(backSleeve)), + m_frontSleeve(std::move(frontSleeve)) {} std::filesystem::path Frames::GetBody() const { return m_body; } @@ -53,18 +53,19 @@ void Frames::SetFrontSleeve(const std::filesystem::path &frontSleeve) { // Item //---------------------------------------------------------------------- -Item::Item(const std::string &itemName, const Rarity rarity) - : m_itemName(itemName), m_price(0), m_maxStack(1), m_rarity(rarity) {} +Item::Item(std::string itemName, const Rarity rarity) + : m_itemName(std::move(itemName)), m_price(0), m_maxStack(1), m_rarity(rarity) {} -Item::Item(const std::string &itemName, - const std::filesystem::path &inventoryIcon, const Category category, - const std::string &description, const std::string &shortDescription, - const Frames &maleFrames, const Frames &femaleFrames) - : m_itemName(itemName), m_price(0), m_inventoryIcon(inventoryIcon), - m_maxStack(1), m_rarity(Rarity::Essential), m_category(category), - m_description(description), m_shortDescription(shortDescription), - m_tooltipKind(TooltipKind::Armor), m_maleFrames(maleFrames), - m_femaleFrames(femaleFrames) {} +Item::Item(std::string itemName, std::filesystem::path inventoryIcon, + const Category category, std::string description, + std::string shortDescription, Frames maleFrames, Frames femaleFrames) + : m_itemName(std::move(itemName)), m_price(0), + m_inventoryIcon(std::move(inventoryIcon)), m_maxStack(1), + m_rarity(Rarity::Essential), m_category(category), + m_description(std::move(description)), + m_shortDescription(std::move(shortDescription)), + m_tooltipKind(TooltipKind::Armor), m_maleFrames(std::move(maleFrames)), + m_femaleFrames(std::move(femaleFrames)) {} std::string Item::GetItemName() const { return m_itemName; } diff --git a/src/starbound/metadata.cpp b/src/starbound/metadata.cpp index 7903313..c3d12e0 100644 --- a/src/starbound/metadata.cpp +++ b/src/starbound/metadata.cpp @@ -26,13 +26,14 @@ namespace Starbound { // Metadata //---------------------------------------------------------------------- -Metadata::Metadata(const std::string &name, const std::string &friendlyName, - const std::string &author, const std::string &description, - const std::string &version, const std::string &link, - const std::vector &_requires) - : m_name(name), m_friendlyName(friendlyName), m_author(author), - m_description(description), m_version(version), m_link(link), - m_requires(_requires), m_priority(0) {} +Metadata::Metadata(std::string name, std::string friendlyName, + std::string author, std::string description, + std::string version, std::string link, + std::vector _requires) + : m_name(std::move(name)), m_friendlyName(std::move(friendlyName)), + m_author(std::move(author)), m_description(std::move(description)), + m_version(std::move(version)), m_link(std::move(link)), + m_requires(std::move(_requires)), m_priority(0) {} std::string Metadata::GetName() const { return m_name; } diff --git a/src/starpounds/species.cpp b/src/starpounds/species.cpp index 6fca377..07560cf 100644 --- a/src/starpounds/species.cpp +++ b/src/starpounds/species.cpp @@ -23,14 +23,13 @@ along with speciesgen. If not, see . namespace Starpounds { SpeciesConfig::SpeciesConfig(const bool fullbright) : m_fullbright(fullbright) {} -SpeciesConfig::SpeciesConfig(const std::string &_override, +SpeciesConfig::SpeciesConfig(std::string _override, const bool fullbright) + : m_fullbright(fullbright), m_override(std::move(_override)) {} +SpeciesConfig::SpeciesConfig(std::string _override, + std::string overrideDirectives, const bool fullbright) - : m_fullbright(fullbright), m_override(_override) {} -SpeciesConfig::SpeciesConfig(const std::string &_override, - const std::string &overrideDirectives, - const bool fullbright) - : m_fullbright(fullbright), m_override(_override), - m_overrideDirectives(overrideDirectives) {} + : m_fullbright(fullbright), m_override(std::move(_override)), + m_overrideDirectives(std::move(overrideDirectives)) {} bool SpeciesConfig::GetFullbright() const { return m_fullbright; } std::string SpeciesConfig::GetOverride() const { return m_override; } diff --git a/src/starpounds/weightstage.cpp b/src/starpounds/weightstage.cpp index 09f14e4..4b6b814 100644 --- a/src/starpounds/weightstage.cpp +++ b/src/starpounds/weightstage.cpp @@ -26,20 +26,20 @@ namespace Starpounds { // WeightStageSub //---------------------------------------------------------------------- -WeightStageSub::WeightStageSub(const std::string &name, - const std::string &friendlyName, - const std::string &descriptionChest, +WeightStageSub::WeightStageSub(std::string name, std::string friendlyName, + std::string descriptionChest, const Types::Chests typeChest) - : m_name(name), m_friendlyName(friendlyName), - m_descriptionChest(descriptionChest), m_typeChest(typeChest) {} + : m_name(std::move(name)), m_friendlyName(std::move(friendlyName)), + m_descriptionChest(std::move(descriptionChest)), m_typeChest(typeChest) {} -WeightStageSub::WeightStageSub(const std::string &name) - : m_name(name), m_typeChest(Types::Chests::Chest) {} +WeightStageSub::WeightStageSub(std::string name) + : m_name(std::move(name)), m_typeChest(Types::Chests::Chest) {} WeightStageSub::WeightStageSub(const Types::Subs type, - const std::string &descriptionChest) + std::string descriptionChest) : m_name(Types::AsString(type)), m_friendlyName(Types::AsFriendly(type)), - m_descriptionChest(descriptionChest), m_typeChest(Types::AsChest(type)) {} + m_descriptionChest(std::move(descriptionChest)), + m_typeChest(Types::AsChest(type)) {} std::string WeightStageSub::GetName() const { return m_name; } @@ -73,17 +73,17 @@ WeightStage::WeightStage(const std::string &name, const std::string &friendlyName, const std::string &descriptionChest, const Types::Chests typeChest, - const std::string &descriptionLeg, - const Types::Legs typeLeg, const bool frames, - const bool id, const std::vector &subs) + std::string descriptionLeg, const Types::Legs typeLeg, + const bool frames, const bool id, + std::vector subs) : WeightStageSub(name, friendlyName, descriptionChest, typeChest), - m_descriptionLeg(descriptionLeg), m_typeLeg(typeLeg), m_frames(frames), - m_id(id), m_subs(subs) {} + m_descriptionLeg(std::move(descriptionLeg)), m_typeLeg(typeLeg), + m_frames(frames), m_id(id), m_subs(std::move(subs)) {} WeightStage::WeightStage(const std::string &name, const bool frames, - const bool id, const std::vector &subs) + const bool id, std::vector subs) : WeightStageSub(name), m_typeLeg(Types::Legs::Legs), m_frames(frames), - m_id(id), m_subs(subs) {} + m_id(id), m_subs(std::move(subs)) {} std::string WeightStage::GetLegDescription() const { return m_descriptionLeg; }