mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:27:45 +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
5 changed files with 22 additions and 1 deletions
|
@ -156,6 +156,11 @@ ErrorOr<String> StringBuilder::to_string() const
|
|||
return String::from_utf8(string_view());
|
||||
}
|
||||
|
||||
String StringBuilder::to_string_without_validation() const
|
||||
{
|
||||
return String::from_utf8_without_validation(string_view().bytes());
|
||||
}
|
||||
|
||||
ErrorOr<FlyString> StringBuilder::to_fly_string() const
|
||||
{
|
||||
return FlyString::from_utf8(string_view());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue