mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
AK+LibJS+LibWeb: Recognize that our UTF-16 string is actually WTF-16
For the web, we allow a wobbly UTF-16 encoding (i.e. lonely surrogates are permitted). Only in a few exceptional cases do we strictly require valid UTF-16. As such, our `validate(AllowLonelySurrogates::Yes)` calls will always succeed. It's a wasted effort to ever make such a check. This patch eliminates such invocations. The validation methods will now only check for strict UTF-16, and are only invoked when needed.
This commit is contained in:
Notes:
github-actions[bot]
2025-08-13 13:57:41 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/8472e469f4e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5762
@@ -27,7 +27,6 @@ public:
|
||||
static Utf16FlyString from_utf8_but_should_be_ported_to_utf16(StringView string) { return from_utf8_without_validation(string); }
|
||||
|
||||
static Utf16FlyString from_utf16(Utf16View const&);
|
||||
static Utf16FlyString from_utf16_without_validation(Utf16View const&);
|
||||
|
||||
template<typename T>
|
||||
requires(IsOneOf<RemoveCVReference<T>, Utf16String, Utf16FlyString>)
|
||||
@@ -193,8 +192,5 @@ inline constexpr bool IsHashCompatible<Utf16FlyString, Utf16String> = true;
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE AK::Utf16FlyString operator""_utf16_fly_string(char16_t const* string, size_t length)
|
||||
{
|
||||
AK::Utf16View view { string, length };
|
||||
|
||||
ASSERT(view.validate());
|
||||
return AK::Utf16FlyString::from_utf16_without_validation(view);
|
||||
return AK::Utf16FlyString::from_utf16({ string, length });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user