diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index f2862b2e1e1..e2008cee3dd 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -58,11 +58,12 @@ ErrorOr utf8_to_utf16(StringView utf8_view, Endianness en ErrorOr utf8_to_utf16(Utf8View const& utf8_view, Endianness endianness) { + if (utf8_view.is_empty()) + return Utf16ConversionResult { Utf16Data {}, 0 }; + // All callers want to allow lonely surrogates, which simdutf does not permit. if (!utf8_view.validate(Utf8View::AllowSurrogates::No)) [[unlikely]] return to_utf16_slow(utf8_view, endianness); - if (utf8_view.is_empty()) - return Utf16ConversionResult { Utf16Data {}, 0 }; auto const* data = reinterpret_cast(utf8_view.bytes()); auto length = utf8_view.byte_length();