mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00: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:
parent
a285e36041
commit
3c039903fb
Notes:
sideshowbarker
2024-07-16 17:12:03 +09:00
Author: https://github.com/awesomekling
Commit: 3c039903fb
Pull-request: https://github.com/SerenityOS/serenity/pull/22496
Reviewed-by: https://github.com/LucasChollet
5 changed files with 22 additions and 1 deletions
|
@ -247,7 +247,7 @@ ErrorOr<String> Decoder::to_utf8(StringView input)
|
|||
{
|
||||
StringBuilder builder(input.length());
|
||||
TRY(process(input, [&builder](u32 c) { return builder.try_append_code_point(c); }));
|
||||
return builder.to_string();
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
ErrorOr<void> UTF8Decoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue