diff --git a/include/loot/database_interface.h b/include/loot/database_interface.h index 488ef644..ee30515e 100644 --- a/include/loot/database_interface.h +++ b/include/loot/database_interface.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "loot/exception/cyclic_interaction_error.h" @@ -175,8 +176,8 @@ public: * exists. */ virtual std::vector GetGroupsPath( - const std::string& fromGroupName, - const std::string& toGroupName) const = 0; + std::string_view fromGroupName, + std::string_view toGroupName) const = 0; /** * @} @@ -200,7 +201,7 @@ public: * otherwise an optional containing no value. */ virtual std::optional GetPluginMetadata( - const std::string& plugin, + std::string_view plugin, bool includeUserMetadata = true, bool evaluateConditions = false) const = 0; @@ -216,7 +217,7 @@ public: * that metadata, otherwise an optional containing no value. */ virtual std::optional GetPluginUserMetadata( - const std::string& plugin, + std::string_view plugin, bool evaluateConditions = false) const = 0; /** @@ -235,7 +236,7 @@ public: * The filename of the plugin for which all user-added metadata * should be deleted. */ - virtual void DiscardPluginUserMetadata(const std::string& plugin) = 0; + virtual void DiscardPluginUserMetadata(std::string_view plugin) = 0; /** * @brief Discards all loaded user metadata for all plugins, and any diff --git a/include/loot/exception/undefined_group_error.h b/include/loot/exception/undefined_group_error.h index 008b3ae0..27dfea1e 100644 --- a/include/loot/exception/undefined_group_error.h +++ b/include/loot/exception/undefined_group_error.h @@ -26,6 +26,7 @@ #define LOOT_EXCEPTION_UNDEFINED_GROUP_ERROR #include +#include #include "loot/api_decorator.h" @@ -39,7 +40,7 @@ public: * @brief Construct an exception for an undefined group. * @param groupName The name of the group that is undefined. */ - LOOT_API UndefinedGroupError(const std::string& groupName); + LOOT_API UndefinedGroupError(std::string_view groupName); /** * Get the name of the undefined group. diff --git a/include/loot/game_interface.h b/include/loot/game_interface.h index a2e39799..3ebcf1f2 100644 --- a/include/loot/game_interface.h +++ b/include/loot/game_interface.h @@ -142,7 +142,7 @@ public: * a case-insensitively equal filename is loaded. */ virtual std::shared_ptr GetPlugin( - const std::string& pluginName) const = 0; + std::string_view pluginName) const = 0; /** * @brief Get a set of const references to all loaded plugins' PluginInterface diff --git a/include/loot/metadata/conditional_metadata.h b/include/loot/metadata/conditional_metadata.h index cd47658b..e175670c 100644 --- a/include/loot/metadata/conditional_metadata.h +++ b/include/loot/metadata/conditional_metadata.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_CONDITIONAL_METADATA #include +#include #include "loot/api_decorator.h" @@ -48,7 +49,7 @@ public: * documentation. * @return A ConditionalMetadata object. */ - LOOT_API explicit ConditionalMetadata(const std::string& condition); + LOOT_API explicit ConditionalMetadata(std::string_view condition); /** * Check if the condition string is non-empty. diff --git a/include/loot/metadata/file.h b/include/loot/metadata/file.h index e7d1934d..526e082d 100644 --- a/include/loot/metadata/file.h +++ b/include/loot/metadata/file.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_FILE #include +#include #include "loot/api_decorator.h" #include "loot/metadata/conditional_metadata.h" @@ -58,9 +59,9 @@ public: * English. * @return A File object. */ - LOOT_API explicit File(const std::string& name, - const std::string& display = "", - const std::string& condition = "", + LOOT_API explicit File(std::string_view name, + std::string_view display = "", + std::string_view condition = "", const std::vector& detail = {}); /** diff --git a/include/loot/metadata/filename.h b/include/loot/metadata/filename.h index b09fa2be..3c7fc9c9 100644 --- a/include/loot/metadata/filename.h +++ b/include/loot/metadata/filename.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_FILENAME #include +#include #include "loot/api_decorator.h" @@ -44,7 +45,7 @@ public: * Construct a Filename using the given string. * @return A Filename object. */ - LOOT_API explicit Filename(const std::string& filename); + LOOT_API explicit Filename(std::string_view filename); /** * Get this Filename as a string. diff --git a/include/loot/metadata/group.h b/include/loot/metadata/group.h index adf78ce3..e553f12a 100644 --- a/include/loot/metadata/group.h +++ b/include/loot/metadata/group.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_GROUP #include +#include #include #include "loot/api_decorator.h" @@ -58,9 +59,9 @@ public: * A description of the group. * @return A Group object. */ - LOOT_API explicit Group(const std::string& name, + LOOT_API explicit Group(std::string_view name, const std::vector& afterGroups = {}, - const std::string& description = ""); + std::string_view description = ""); /** * Get the name of the group. diff --git a/include/loot/metadata/location.h b/include/loot/metadata/location.h index 66b319f7..7f32eca4 100644 --- a/include/loot/metadata/location.h +++ b/include/loot/metadata/location.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_LOCATION #include +#include #include #include "loot/api_decorator.h" @@ -49,8 +50,8 @@ public: * A name for the URL, eg. the page or site name. * @return A Location object. */ - LOOT_API explicit Location(const std::string& url, - const std::string& name = ""); + LOOT_API explicit Location(std::string_view url, + std::string_view name = ""); /** * Get the object's URL. diff --git a/include/loot/metadata/message.h b/include/loot/metadata/message.h index 735d59b1..1509a640 100644 --- a/include/loot/metadata/message.h +++ b/include/loot/metadata/message.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_MESSAGE #include +#include #include #include "loot/api_decorator.h" @@ -57,8 +58,8 @@ public: * @return A Message object. */ LOOT_API explicit Message(const MessageType type, - const std::string& content, - const std::string& condition = ""); + std::string_view content, + std::string_view condition = ""); /** * Construct a Message object with the given type, content and condition @@ -73,7 +74,7 @@ public: */ LOOT_API explicit Message(const MessageType type, const std::vector& content, - const std::string& condition = ""); + std::string_view condition = ""); /** * Get the message type. diff --git a/include/loot/metadata/message_content.h b/include/loot/metadata/message_content.h index 9a3b4c07..6fef605c 100644 --- a/include/loot/metadata/message_content.h +++ b/include/loot/metadata/message_content.h @@ -26,6 +26,7 @@ #include #include +#include #include #include "loot/api_decorator.h" @@ -57,8 +58,8 @@ public: * @return A MessageContent object. */ LOOT_API explicit MessageContent( - const std::string& text, - const std::string& language = DEFAULT_LANGUAGE); + std::string_view text, + std::string_view language = DEFAULT_LANGUAGE); /** * Get the message text. @@ -144,7 +145,7 @@ LOOT_API bool operator>=(const MessageContent& lhs, const MessageContent& rhs); */ LOOT_API std::optional SelectMessageContent( const std::vector content, - const std::string& language); + std::string_view language); } #endif diff --git a/include/loot/metadata/plugin_cleaning_data.h b/include/loot/metadata/plugin_cleaning_data.h index 8ed59662..bb429927 100644 --- a/include/loot/metadata/plugin_cleaning_data.h +++ b/include/loot/metadata/plugin_cleaning_data.h @@ -27,6 +27,7 @@ #include #include +#include #include "loot/api_decorator.h" #include "loot/metadata/message.h" @@ -57,7 +58,7 @@ public: * @return A PluginCleaningData object. */ LOOT_API explicit PluginCleaningData(uint32_t crc, - const std::string& utility); + std::string_view utility); /** * Construct a PluginCleaningData object with the given values. @@ -78,7 +79,7 @@ public: */ LOOT_API explicit PluginCleaningData( uint32_t crc, - const std::string& utility, + std::string_view utility, const std::vector& detail, unsigned int itm, unsigned int ref, diff --git a/include/loot/metadata/plugin_metadata.h b/include/loot/metadata/plugin_metadata.h index da821a90..59619544 100644 --- a/include/loot/metadata/plugin_metadata.h +++ b/include/loot/metadata/plugin_metadata.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "loot/api_decorator.h" @@ -58,7 +59,7 @@ public: * The filename of the plugin that the object is constructed for. * @return A PluginMetadata object. */ - LOOT_API explicit PluginMetadata(const std::string& name); + LOOT_API explicit PluginMetadata(std::string_view name); /** * Merge metadata from the given PluginMetadata object into this object. @@ -138,7 +139,7 @@ public: * @param group * The name of the group this plugin belongs to. */ - LOOT_API void SetGroup(const std::string& group); + LOOT_API void SetGroup(std::string_view group); /** * Unsets the plugin's group. @@ -227,7 +228,7 @@ public: * @returns True if the given plugin name matches this metadata's plugin * name, false otherwise. */ - LOOT_API bool NameMatches(const std::string& pluginName) const; + LOOT_API bool NameMatches(std::string_view pluginName) const; /** * @brief Serialises the plugin metadata as YAML. diff --git a/include/loot/metadata/tag.h b/include/loot/metadata/tag.h index 1138b3cc..09f9249e 100644 --- a/include/loot/metadata/tag.h +++ b/include/loot/metadata/tag.h @@ -25,6 +25,7 @@ #define LOOT_METADATA_TAG #include +#include #include "loot/api_decorator.h" #include "loot/metadata/conditional_metadata.h" @@ -53,9 +54,9 @@ public: * A condition string. * @return A Tag object. */ - LOOT_API explicit Tag(const std::string& tag, + LOOT_API explicit Tag(std::string_view tag, const bool isAddition = true, - const std::string& condition = ""); + std::string_view condition = ""); /** * Check if the tag should be added. diff --git a/include/loot/plugin_interface.h b/include/loot/plugin_interface.h index 4bec165d..1d7621ac 100644 --- a/include/loot/plugin_interface.h +++ b/include/loot/plugin_interface.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "loot/metadata/message.h" diff --git a/include/loot/vertex.h b/include/loot/vertex.h index 861d652c..f18de6b3 100644 --- a/include/loot/vertex.h +++ b/include/loot/vertex.h @@ -27,6 +27,7 @@ along with LOOT. If not, see #include #include +#include #include "loot/api_decorator.h" #include "loot/enum/edge_type.h" @@ -42,14 +43,14 @@ public: * @brief Construct a Vertex with the given name and no out edge. * @param name The name of the plugin or group that this vertex represents. */ - LOOT_API explicit Vertex(std::string name); + LOOT_API explicit Vertex(std::string_view name); /** * @brief Construct a Vertex with the given name and out edge type. * @param name The name of the plugin or group that this vertex represents. * @param outEdgeType The type of the edge going out from this vertex. */ - LOOT_API explicit Vertex(std::string name, EdgeType outEdgeType); + LOOT_API explicit Vertex(std::string_view name, EdgeType outEdgeType); /** * @brief Get the name of the plugin or group. diff --git a/src/api/api_database.cpp b/src/api/api_database.cpp index a82a901a..e1c1794c 100644 --- a/src/api/api_database.cpp +++ b/src/api/api_database.cpp @@ -203,8 +203,8 @@ void ApiDatabase::SetUserGroups(const std::vector& groups) { } std::vector ApiDatabase::GetGroupsPath( - const std::string& fromGroupName, - const std::string& toGroupName) const { + std::string_view fromGroupName, + std::string_view toGroupName) const { auto masterlistGroups = GetGroups(false); auto userGroups = GetUserGroups(); @@ -214,7 +214,7 @@ std::vector ApiDatabase::GetGroupsPath( } std::optional ApiDatabase::GetPluginMetadata( - const std::string& plugin, + std::string_view plugin, bool includeUserMetadata, bool evaluateConditions) const { auto metadata = masterlist_.FindPlugin(plugin); @@ -237,7 +237,7 @@ std::optional ApiDatabase::GetPluginMetadata( } std::optional ApiDatabase::GetPluginUserMetadata( - const std::string& plugin, + std::string_view plugin, bool evaluateConditions) const { auto metadata = userlist_.FindPlugin(plugin); @@ -253,7 +253,7 @@ void ApiDatabase::SetPluginUserMetadata(const PluginMetadata& pluginMetadata) { userlist_.AddPlugin(pluginMetadata); } -void ApiDatabase::DiscardPluginUserMetadata(const std::string& plugin) { +void ApiDatabase::DiscardPluginUserMetadata(std::string_view plugin) { userlist_.ErasePlugin(plugin); } diff --git a/src/api/api_database.h b/src/api/api_database.h index 161396d4..88931d38 100644 --- a/src/api/api_database.h +++ b/src/api/api_database.h @@ -64,21 +64,21 @@ struct ApiDatabase final : public DatabaseInterface { std::vector GetUserGroups() const override; void SetUserGroups(const std::vector& groups) override; std::vector GetGroupsPath( - const std::string& fromGroupName, - const std::string& toGroupName) const override; + std::string_view fromGroupName, + std::string_view toGroupName) const override; std::optional GetPluginMetadata( - const std::string& plugin, + std::string_view plugin, bool includeUserMetadata = true, bool evaluateConditions = false) const override; std::optional GetPluginUserMetadata( - const std::string& plugin, + std::string_view plugin, bool evaluateConditions = false) const override; void SetPluginUserMetadata(const PluginMetadata& pluginMetadata) override; - void DiscardPluginUserMetadata(const std::string& plugin) override; + void DiscardPluginUserMetadata(std::string_view plugin) override; void DiscardAllUserMetadata() override; diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index 7de857fc..812fa6b8 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -312,7 +312,7 @@ void Game::LoadPlugins(const std::vector& pluginPaths, void Game::ClearLoadedPlugins() { cache_.ClearCachedPlugins(); } std::shared_ptr Game::GetPlugin( - const std::string& pluginName) const { + std::string_view pluginName) const { return cache_.GetPlugin(pluginName); } @@ -380,7 +380,7 @@ std::filesystem::path Game::GetActivePluginsFilePath() const { } bool Game::IsPluginActive(const std::string& pluginName) const { - return loadOrderHandler_.IsPluginActive(pluginName); + return loadOrderHandler_.IsPluginActive(std::string(pluginName)); } std::vector Game::GetLoadOrder() const { diff --git a/src/api/game/game.h b/src/api/game/game.h index cc60048c..7733faba 100644 --- a/src/api/game/game.h +++ b/src/api/game/game.h @@ -73,7 +73,7 @@ public: void ClearLoadedPlugins() override; std::shared_ptr GetPlugin( - const std::string& pluginName) const override; + std::string_view pluginName) const override; std::vector> GetLoadedPlugins() const override; diff --git a/src/api/game/load_order_handler.cpp b/src/api/game/load_order_handler.cpp index aca230c6..f071dc65 100644 --- a/src/api/game/load_order_handler.cpp +++ b/src/api/game/load_order_handler.cpp @@ -203,7 +203,7 @@ std::filesystem::path LoadOrderHandler::GetActivePluginsFilePath() const { HandleError("get active plugins file path", ret); - const auto filePath = std::filesystem::u8path(std::string(filePathCString)); + const auto filePath = std::filesystem::u8path(std::string_view(filePathCString)); lo_free_string(filePathCString); @@ -227,7 +227,7 @@ std::vector LoadOrderHandler::GetAdditionalDataPaths() std::vector loadOrder; for (size_t i = 0; i < pathArrSize; i += 1) { - loadOrder.push_back(std::filesystem::u8path(std::string(pathArr[i]))); + loadOrder.push_back(std::filesystem::u8path(std::string_view(pathArr[i]))); } lo_free_string_array(pathArr, pathArrSize); diff --git a/src/api/metadata/conditional_metadata.cpp b/src/api/metadata/conditional_metadata.cpp index f778f686..c660ed80 100644 --- a/src/api/metadata/conditional_metadata.cpp +++ b/src/api/metadata/conditional_metadata.cpp @@ -25,7 +25,7 @@ #include "loot/metadata/conditional_metadata.h" namespace loot { -ConditionalMetadata::ConditionalMetadata(const std::string& condition) : +ConditionalMetadata::ConditionalMetadata(std::string_view condition) : condition_(condition) {} bool ConditionalMetadata::IsConditional() const { return !condition_.empty(); } diff --git a/src/api/metadata/file.cpp b/src/api/metadata/file.cpp index 132ec0fa..d8fd09b8 100644 --- a/src/api/metadata/file.cpp +++ b/src/api/metadata/file.cpp @@ -25,9 +25,9 @@ #include "loot/metadata/file.h" namespace loot { -File::File(const std::string& name, - const std::string& display, - const std::string& condition, +File::File(std::string_view name, + std::string_view display, + std::string_view condition, const std::vector& detail) : ConditionalMetadata(condition), name_(Filename(name)), diff --git a/src/api/metadata/filename.cpp b/src/api/metadata/filename.cpp index 771b6113..04c2be6e 100644 --- a/src/api/metadata/filename.cpp +++ b/src/api/metadata/filename.cpp @@ -27,7 +27,7 @@ #include "api/helpers/text.h" namespace loot { -Filename::Filename(const std::string& filename) : filename_(filename) {} +Filename::Filename(std::string_view filename) : filename_(filename) {} Filename::operator std::string() const { return filename_; } diff --git a/src/api/metadata/group.cpp b/src/api/metadata/group.cpp index a3117f16..4205d17f 100644 --- a/src/api/metadata/group.cpp +++ b/src/api/metadata/group.cpp @@ -25,9 +25,9 @@ #include "loot/metadata/group.h" namespace loot { -Group::Group(const std::string& name, +Group::Group(std::string_view name, const std::vector& afterGroups, - const std::string& description) : + std::string_view description) : name_(name), description_(description), afterGroups_(afterGroups) {} std::string Group::GetName() const { return name_; } diff --git a/src/api/metadata/location.cpp b/src/api/metadata/location.cpp index ac669ee6..7b540212 100644 --- a/src/api/metadata/location.cpp +++ b/src/api/metadata/location.cpp @@ -25,7 +25,7 @@ #include "loot/metadata/location.h" namespace loot { -Location::Location(const std::string& url, const std::string& name) : +Location::Location(std::string_view url, std::string_view name) : url_(url), name_(name) {} std::string Location::GetURL() const { return url_; } diff --git a/src/api/metadata/message.cpp b/src/api/metadata/message.cpp index ca152ab2..c3dec404 100644 --- a/src/api/metadata/message.cpp +++ b/src/api/metadata/message.cpp @@ -28,15 +28,15 @@ namespace loot { Message::Message(const MessageType type, - const std::string& content, - const std::string& condition) : + std::string_view content, + std::string_view condition) : ConditionalMetadata(condition), type_(type), content_({MessageContent(content)}) {} Message::Message(const MessageType type, const std::vector& content, - const std::string& condition) : + std::string_view condition) : ConditionalMetadata(condition), type_(type), content_(content) { if (content.size() > 1) { bool englishStringExists = false; diff --git a/src/api/metadata/message_content.cpp b/src/api/metadata/message_content.cpp index 4458551a..c184af48 100644 --- a/src/api/metadata/message_content.cpp +++ b/src/api/metadata/message_content.cpp @@ -25,8 +25,8 @@ #include "loot/metadata/message_content.h" namespace loot { -MessageContent::MessageContent(const std::string& text, - const std::string& language) : +MessageContent::MessageContent(std::string_view text, + std::string_view language) : text_(text), language_(language) {} std::string MessageContent::GetText() const { return text_; } @@ -68,7 +68,7 @@ bool operator>=(const MessageContent& lhs, const MessageContent& rhs) { std::optional SelectMessageContent( const std::vector content, - const std::string& language) { + std::string_view language) { if (content.empty()) return std::nullopt; else if (content.size() == 1) diff --git a/src/api/metadata/plugin_cleaning_data.cpp b/src/api/metadata/plugin_cleaning_data.cpp index 8dc5d9fc..fd5b12d7 100644 --- a/src/api/metadata/plugin_cleaning_data.cpp +++ b/src/api/metadata/plugin_cleaning_data.cpp @@ -26,12 +26,12 @@ namespace loot { PluginCleaningData::PluginCleaningData(uint32_t crc, - const std::string& utility) : + std::string_view utility) : crc_(crc), utility_(utility) {} PluginCleaningData::PluginCleaningData( uint32_t crc, - const std::string& utility, + std::string_view utility, const std::vector& detail, unsigned int itm, unsigned int ref, diff --git a/src/api/metadata/plugin_metadata.cpp b/src/api/metadata/plugin_metadata.cpp index ce880e62..4d78db5b 100644 --- a/src/api/metadata/plugin_metadata.cpp +++ b/src/api/metadata/plugin_metadata.cpp @@ -51,7 +51,7 @@ std::vector mergeVectors(std::vector first, namespace loot { // If the name passed ends in '.ghost', that should be trimmed. -PluginMetadata::PluginMetadata(const std::string& n) : +PluginMetadata::PluginMetadata(std::string_view n) : name_(TrimDotGhostExtension(std::string(n))) { if (IsRegexPlugin()) { nameRegex_ = std::regex(name_, std::regex::ECMAScript | std::regex::icase); @@ -116,7 +116,7 @@ std::vector PluginMetadata::GetLocations() const { return locations_; } -void PluginMetadata::SetGroup(const std::string& group) { group_ = group; } +void PluginMetadata::SetGroup(std::string_view group) { group_ = group; } void PluginMetadata::UnsetGroup() { group_ = std::nullopt; } @@ -164,13 +164,13 @@ bool PluginMetadata::IsRegexPlugin() const { return strpbrk(name_.c_str(), ":\\*?|") != nullptr; } -bool PluginMetadata::NameMatches(const std::string& pluginName) const { +bool PluginMetadata::NameMatches(std::string_view pluginName) const { if (IsRegexPlugin()) { if (!nameRegex_.has_value()) { throw std::runtime_error("Regex plugin does not have regex object"); } - return std::regex_match(pluginName, nameRegex_.value()); + return std::regex_match(pluginName.begin(), pluginName.end(), nameRegex_.value()); } return CompareFilenames(name_, pluginName) == 0; diff --git a/src/api/metadata/tag.cpp b/src/api/metadata/tag.cpp index 1a551ad5..80640d0b 100644 --- a/src/api/metadata/tag.cpp +++ b/src/api/metadata/tag.cpp @@ -25,9 +25,9 @@ #include "loot/metadata/tag.h" namespace loot { -Tag::Tag(const std::string& tag, +Tag::Tag(std::string_view tag, const bool isAddition, - const std::string& condition) : + std::string_view condition) : ConditionalMetadata(condition), name_(tag), addTag_(isAddition) {} bool Tag::IsAddition() const { return addTag_; } diff --git a/src/api/metadata_list.cpp b/src/api/metadata_list.cpp index 1364af4a..c253b436 100644 --- a/src/api/metadata_list.cpp +++ b/src/api/metadata_list.cpp @@ -320,7 +320,7 @@ void MetadataList::SetGroups(const std::vector& groups) { // Merges multiple matching regex entries if any are found. std::optional MetadataList::FindPlugin( - const std::string& pluginName) const { + std::string_view pluginName) const { PluginMetadata match(pluginName); const auto it = plugins_.find(Filename(pluginName)); @@ -359,7 +359,7 @@ void MetadataList::AddPlugin(const PluginMetadata& plugin) { // Doesn't erase matching regex entries, because they might also // be required for other plugins. -void MetadataList::ErasePlugin(const std::string& pluginName) { +void MetadataList::ErasePlugin(std::string_view pluginName) { const auto it = plugins_.find(Filename(pluginName)); if (it != plugins_.end()) { diff --git a/src/api/metadata_list.h b/src/api/metadata_list.h index 3d3ca8f0..1eef8705 100644 --- a/src/api/metadata_list.h +++ b/src/api/metadata_list.h @@ -70,12 +70,12 @@ public: void SetGroups(const std::vector& groups); // Merges multiple matching regex entries if any are found. - std::optional FindPlugin(const std::string& pluginName) const; + std::optional FindPlugin(std::string_view pluginName) const; void AddPlugin(const PluginMetadata& plugin); // Doesn't erase matching regex entries, because they might also // be required for other plugins. - void ErasePlugin(const std::string& pluginName); + void ErasePlugin(std::string_view pluginName); void AppendMessage(const Message& message); diff --git a/src/api/sorting/undefined_group_error.cpp b/src/api/sorting/undefined_group_error.cpp index c955d1ce..4b6ce90d 100644 --- a/src/api/sorting/undefined_group_error.cpp +++ b/src/api/sorting/undefined_group_error.cpp @@ -24,8 +24,8 @@ #include "loot/exception/undefined_group_error.h" namespace loot { -UndefinedGroupError::UndefinedGroupError(const std::string& groupName) : - std::runtime_error("The group \"" + groupName + "\" does not exist"), +UndefinedGroupError::UndefinedGroupError(std::string_view groupName) : + std::runtime_error("The group \"" + std::string(groupName) + "\" does not exist"), groupName_(groupName) {} std::string UndefinedGroupError::GetGroupName() const { return groupName_; } diff --git a/src/api/vertex.cpp b/src/api/vertex.cpp index fb6a345b..ee1bf9af 100644 --- a/src/api/vertex.cpp +++ b/src/api/vertex.cpp @@ -24,9 +24,9 @@ #include "loot/vertex.h" namespace loot { -Vertex::Vertex(std::string name) : name_(name) {} +Vertex::Vertex(std::string_view name) : name_(name) {} -Vertex::Vertex(std::string name, EdgeType outEdgeType) : +Vertex::Vertex(std::string_view name, EdgeType outEdgeType) : name_(name), outEdgeType_(outEdgeType) {} std::string Vertex::GetName() const { return name_; }