AK: Make ""_string and ""_fly_string literals skip UTF-8 validation

We still validate in an ASSERT, but let's not bother with this in
release builds.
This commit is contained in:
Andreas Kling 2025-04-08 23:25:26 +02:00
parent cd72e788e9
commit dfade03777
2 changed files with 4 additions and 2 deletions

View file

@ -217,7 +217,8 @@ struct ASCIICaseInsensitiveFlyStringTraits : public Traits<String> {
[[nodiscard]] ALWAYS_INLINE AK::FlyString operator""_fly_string(char const* cstring, size_t length)
{
return AK::FlyString::from_utf8(AK::StringView(cstring, length)).release_value();
ASSERT(Utf8View(AK::StringView(cstring, length)).validate());
return AK::FlyString::from_utf8_without_validation({ cstring, length });
}
#if USING_AK_GLOBALLY

View file

@ -354,5 +354,6 @@ struct ASCIICaseInsensitiveStringTraits : public Traits<String> {
[[nodiscard]] ALWAYS_INLINE AK::String operator""_string(char const* cstring, size_t length)
{
return AK::String::from_utf8(AK::StringView(cstring, length)).release_value();
ASSERT(Utf8View(AK::StringView(cstring, length)).validate());
return AK::String::from_utf8_without_validation({ cstring, length });
}