-
Notifications
You must be signed in to change notification settings - Fork 10
Description
In some cases a string reference is needed (e.g. when checking if a string is in a map) or a null-terminated string is needed (e.g. when calling C APIs), so a const std::string& makes more sense, but otherwise it can mean an unnecessary copy of the string to create a std::string if the caller doesn't already have one.
I noticed this recently when writing the C++ wrapper for libloot-rs as its CXX wrapper returns many strings using its own equivalent of std::string_view, so I was having to create copies of the strings just to pass them into functions where they may just be read or may be copied again.
This impacts:
- The
ConditionalMetadataconstructor - The
Fileconstructor - The
Filenameconstructor - The
Groupconstructor - The
Locationconstructor - The
MessageContentconstructor - The
Messageconstructor - The
PluginCleaningDataconstructor - The
PluginMetadataconstructor - The
Tagconstructor - The
Vertexconstructor PluginMetadata::SetGroup()PluginMetadata::NameMatches()SelectMessageContent()DatabaseInterface::GetGroupsPath()DatabaseInterface::GetPluginMetadata()DatabaseInterface::GetPluginUserMetadata()DatabaseInterface::DiscardPluginUserMetadata()GameInterface::GetPlugin()GameInterface::IsPluginActive()
Since there's an implicit conversion for std::string to std::string_view, this shouldn't require any consumer changes. It is a breaking change though.