AK+Everywhere: Prepare Utf16View for integration with a UTF-16 string

To prepare for an upcoming Utf16String, this migrates Utf16View to store
its data as a char16_t. Most function definitions are moved inline and
made constexpr.

This also adds a UDL to construct a Utf16View from a string literal:

    auto string = u"hello"sv;

This let's us remove the NTTP Utf16View constructor, as we have found
that such constructors bloat binary size quite a bit.
This commit is contained in:
Timothy Flynn 2025-06-26 12:52:23 -04:00 committed by Tim Flynn
commit 86b1c78c1a
Notes: github-actions[bot] 2025-07-03 13:53:23 +00:00
17 changed files with 406 additions and 421 deletions

View file

@ -212,7 +212,7 @@ String StringView::to_ascii_lowercase_string() const
String result;
MUST(result.replace_with_new_string({}, length(), [&](Bytes buffer) -> ErrorOr<void> {
MUST(result.replace_with_new_string(Badge<StringView> {}, length(), [&](Bytes buffer) -> ErrorOr<void> {
for (auto [i, character] : enumerate(bytes()))
buffer[i] = static_cast<u8>(AK::to_ascii_lowercase(character));
return {};
@ -227,7 +227,7 @@ String StringView::to_ascii_uppercase_string() const
String result;
MUST(result.replace_with_new_string({}, length(), [&](Bytes buffer) -> ErrorOr<void> {
MUST(result.replace_with_new_string(Badge<StringView> {}, length(), [&](Bytes buffer) -> ErrorOr<void> {
for (auto [i, character] : enumerate(bytes()))
buffer[i] = static_cast<u8>(AK::to_ascii_uppercase(character));
return {};