summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMax Kellermann <mk@cm4all.com>2021-01-14 13:16:52 +0100
committerMax Kellermann <max@musicpd.org>2021-01-21 18:05:51 +0100
commita81c9bfb813f637ecc1e9351a2022f5f64a1ff91 (patch)
tree6bc185a336b84a5a975b62565820a7c9e257b193 /src/lib
parent1caf57644f5ffa403e73c66d2c345cc22049d826 (diff)
util/AllocatedString: add string_view constructor
Replaces the static Duplicate() method.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/icu/CaseFold.cxx6
-rw-r--r--src/lib/icu/Compare.cxx2
-rw-r--r--src/lib/icu/Converter.cxx4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/icu/CaseFold.cxx b/src/lib/icu/CaseFold.cxx
index ebb75f324..ec7ca80fb 100644
--- a/src/lib/icu/CaseFold.cxx
+++ b/src/lib/icu/CaseFold.cxx
@@ -44,7 +44,7 @@ try {
#ifdef HAVE_ICU
const auto u = UCharFromUTF8(src);
if (u.IsNull())
- return AllocatedString::Duplicate(src);
+ return AllocatedString(src);
AllocatedArray<UChar> folded(u.size() * 2U);
@@ -54,7 +54,7 @@ try {
U_FOLD_CASE_DEFAULT,
&error_code);
if (folded_length == 0 || error_code != U_ZERO_ERROR)
- return AllocatedString::Duplicate(src);
+ return AllocatedString(src);
folded.SetSize(folded_length);
return UCharToUTF8({folded.begin(), folded.size()});
@@ -63,7 +63,7 @@ try {
#error not implemented
#endif
} catch (...) {
- return AllocatedString::Duplicate(src);
+ return AllocatedString(src);
}
#endif /* HAVE_ICU_CASE_FOLD */
diff --git a/src/lib/icu/Compare.cxx b/src/lib/icu/Compare.cxx
index 6bc82bdd5..dfc5d2210 100644
--- a/src/lib/icu/Compare.cxx
+++ b/src/lib/icu/Compare.cxx
@@ -46,7 +46,7 @@ IcuCompare::IcuCompare(std::string_view _needle) noexcept
#else
IcuCompare::IcuCompare(std::string_view _needle) noexcept
- :needle(AllocatedString::Duplicate(_needle)) {}
+ :needle(_needle) {}
#endif
diff --git a/src/lib/icu/Converter.cxx b/src/lib/icu/Converter.cxx
index a231668a8..6123c2490 100644
--- a/src/lib/icu/Converter.cxx
+++ b/src/lib/icu/Converter.cxx
@@ -95,7 +95,7 @@ DoConvert(iconv_t conv, std::string_view src)
if (in_left > 0)
throw std::runtime_error("Charset conversion failed");
- return AllocatedString::Duplicate({buffer, sizeof(buffer) - out_left});
+ return AllocatedString({buffer, sizeof(buffer) - out_left});
}
#endif
@@ -151,7 +151,7 @@ IcuConverter::FromUTF8(std::string_view s) const
throw std::runtime_error(FormatString("Failed to convert from Unicode: %s",
u_errorName(code)).c_str());
- return AllocatedString::Duplicate({buffer, size_t(target - buffer)});
+ return AllocatedString({buffer, size_t(target - buffer)});
#elif defined(HAVE_ICONV)
return DoConvert(from_utf8, s);