util/AllocatedString: add string_view constructor
Replaces the static Duplicate() method.
This commit is contained in:
committed by
Max Kellermann
parent
32b7b2e2fa
commit
6e1c8edf09
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user