AK: Add a couple of validation-skipping UTF-16 string factories

String and FlyString are known to be valid UTF-8, so we can skip
validation when constructing a UTF-16 string from them.
This commit is contained in:
Timothy Flynn 2025-08-03 10:45:05 -04:00 committed by Tim Flynn
commit cd276235d7
Notes: github-actions[bot] 2025-08-05 11:08:38 +00:00
2 changed files with 7 additions and 0 deletions

View file

@ -21,6 +21,8 @@ public:
constexpr Utf16FlyString() = default;
static Utf16FlyString from_utf8(StringView);
static Utf16FlyString from_utf8(String const& string) { return from_utf8_without_validation(string); }
static Utf16FlyString from_utf8(FlyString const& string) { return from_utf8_without_validation(string); }
static Utf16FlyString from_utf8_without_validation(StringView);
static Utf16FlyString from_utf8_but_should_be_ported_to_utf16(StringView string) { return from_utf8_without_validation(string); }

View file

@ -45,6 +45,11 @@ public:
return from_utf8_without_validation(utf8_string);
}
ALWAYS_INLINE static Utf16String from_utf8(FlyString const& utf8_string)
{
return from_utf8_without_validation(utf8_string);
}
enum class WithBOMHandling {
No,
Yes,