1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

LibTextCodec+AK: Don't validate UTF-8 strings twice

UTF8Decoder was already converting invalid data into replacement
characters while converting, so we know for sure we have valid UTF-8
by the time conversion is finished.

This patch adds a new StringBuilder::to_string_without_validation()
and uses it to make UTF8Decoder avoid half the work it was doing.
This commit is contained in:
Andreas Kling 2023-12-29 15:30:15 +01:00
parent a285e36041
commit 3c039903fb
Notes: sideshowbarker 2024-07-16 17:12:03 +09:00
5 changed files with 22 additions and 1 deletions

View file

@ -70,6 +70,8 @@ public:
requires(IsOneOf<RemoveCVReference<T>, ByteString, DeprecatedFlyString, FlyString, String>)
static ErrorOr<String> from_utf8(T&&) = delete;
[[nodiscard]] static String from_utf8_without_validation(ReadonlyBytes);
// Creates a new String by reading byte_count bytes from a UTF-8 encoded Stream.
static ErrorOr<String> from_stream(Stream&, size_t byte_count);