mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Use string_view inputs for conversion functions (flutter/engine#26031)
This offers a small improvement in performance in cases where the input is a raw char* or wchar_t* string due to not having to perform an implicit conversion to std::string/std::wstring. Code cleanup covered by existing tests, which already use raw C strings.
This commit is contained in:
parent
a10ad99348
commit
83dcf51c7b
@ -8,7 +8,7 @@
|
||||
|
||||
namespace flutter {
|
||||
|
||||
std::string Utf8FromUtf16(const std::wstring& utf16_string) {
|
||||
std::string Utf8FromUtf16(const std::wstring_view utf16_string) {
|
||||
if (utf16_string.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
@ -30,7 +30,7 @@ std::string Utf8FromUtf16(const std::wstring& utf16_string) {
|
||||
return utf8_string;
|
||||
}
|
||||
|
||||
std::wstring Utf16FromUtf8(const std::string& utf8_string) {
|
||||
std::wstring Utf16FromUtf8(const std::string_view utf8_string) {
|
||||
if (utf8_string.empty()) {
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
@ -11,11 +11,11 @@ namespace flutter {
|
||||
|
||||
// Converts a string from UTF-16 to UTF-8. Returns an empty string if the
|
||||
// input is not valid UTF-16.
|
||||
std::string Utf8FromUtf16(const std::wstring& utf16_string);
|
||||
std::string Utf8FromUtf16(const std::wstring_view utf16_string);
|
||||
|
||||
// Converts a string from UTF-8 to UTF-16. Returns an empty string if the
|
||||
// input is not valid UTF-8.
|
||||
std::wstring Utf16FromUtf8(const std::string& utf8_string);
|
||||
std::wstring Utf16FromUtf8(const std::string_view utf8_string);
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user