From 1e8cc97b731871409316c121e637c32806135122 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 11 Aug 2024 14:48:30 +1200 Subject: [PATCH] AK: Add fast-path in from_utf8_with_replacement_character for utf-8 This ports the same optimization which was made in 1a46d8df5fc81eb2c320d5c8a5597285d3d8fb3a to this function as well. --- AK/String.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AK/String.cpp b/AK/String.cpp index fd4c50c33e5..cb642ec01f7 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -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 })