mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
AK: Add trim methods to Utf16String that skip allocation when not needed
If the string does not begin with any of the provided code units, we do not need to create a new string.
This commit is contained in:
parent
0efa98a57a
commit
2dc0a3b3ce
Notes:
github-actions[bot]
2025-08-05 13:15:06 +00:00
Author: https://github.com/trflynn89
Commit: 2dc0a3b3ce
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5720
Reviewed-by: https://github.com/gmta ✅
5 changed files with 84 additions and 5 deletions
|
|
@ -105,7 +105,7 @@ Utf16String strip_and_collapse_whitespace(Utf16String const& string)
|
|||
}
|
||||
|
||||
// ...and then remove any leading and trailing ASCII whitespace from that string.
|
||||
return Utf16String::from_utf16(builder.utf16_string_view().trim(Infra::ASCII_WHITESPACE));
|
||||
return builder.to_utf16_string().trim(Infra::ASCII_WHITESPACE);
|
||||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#code-unit-prefix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue