AK: Add fast-path in from_utf8_with_replacement_character for utf-8

This ports the same optimization which was made in
1a46d8df5f to this function as well.
This commit is contained in:
Shannon Booth 2024-08-11 14:48:30 +12:00 committed by Tim Flynn
parent c68b8b5bda
commit 1e8cc97b73
Notes: github-actions[bot] 2024-08-12 10:40:01 +00:00

View file

@ -22,6 +22,9 @@ namespace AK {
String String::from_utf8_with_replacement_character(StringView view)
{
if (Utf8View(view).validate())
return String::from_utf8_without_validation(view.bytes());
StringBuilder builder;
for (auto c : Utf8View { view })