Pass string_view by value

This commit is contained in:
Dennis Luxen 2022-11-04 11:41:02 +01:00
parent 2c02d4e5ab
commit 5280ca4e16
2 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ class SuffixTable final
// check whether a string is part of the know suffix list // check whether a string is part of the know suffix list
bool isSuffix(const std::string &possible_suffix) const; bool isSuffix(const std::string &possible_suffix) const;
bool isSuffix(std::string_view possible_suffix) const; bool isSuffix(std::string_view& possible_suffix) const;
private: private:
// Store lower-cased strings in SuffixTable and a set of StringViews for quick membership // Store lower-cased strings in SuffixTable and a set of StringViews for quick membership

View File

@ -27,8 +27,8 @@ namespace guidance
// Name Change Logic // Name Change Logic
// Used both during Extraction as well as during Post-Processing // Used both during Extraction as well as during Post-Processing
inline std::string_view longest_common_substring(const std::string_view &lhs, inline std::string_view longest_common_substring(const std::string_view lhs,
const std::string_view &rhs) const std::string_view rhs)
{ {
if (lhs.empty() || rhs.empty()) if (lhs.empty() || rhs.empty())
return ""; return "";
@ -131,8 +131,8 @@ inline bool requiresNameAnnounced(const StringView &from_name,
const auto name_is_contained = const auto name_is_contained =
boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name); boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name);
const auto checkForPrefixOrSuffixChange = [](const std::string_view &first, const auto checkForPrefixOrSuffixChange = [](const std::string_view first,
const std::string_view &second, const std::string_view second,
const SuffixTable &suffix_table) { const SuffixTable &suffix_table) {
std::string first_prefix, first_suffix, second_prefix, second_suffix; std::string first_prefix, first_suffix, second_prefix, second_suffix;
std::tie(first_prefix, first_suffix, second_prefix, second_suffix) = std::tie(first_prefix, first_suffix, second_prefix, second_suffix) =
@ -203,7 +203,7 @@ inline bool requiresNameAnnounced(const std::string &from_name,
struct NopSuffixTable final struct NopSuffixTable final
{ {
NopSuffixTable() {} NopSuffixTable() {}
bool isSuffix(const std::string_view &) const { return false; } bool isSuffix(const std::string_view) const { return false; }
} static const table; } static const table;
return requiresNameAnnounced(std::string_view(from_name), return requiresNameAnnounced(std::string_view(from_name),