mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-07 00:29:47 +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
|
@ -1644,8 +1644,7 @@ Utf16String HTMLInputElement::value_sanitization_algorithm(Utf16String const& va
|
|||
};
|
||||
|
||||
auto strip_newlines_and_trim = [&]() {
|
||||
auto value_without_newlines = strip_newlines();
|
||||
return Utf16String::from_utf16_without_validation(value_without_newlines.utf16_view().trim(Infra::ASCII_WHITESPACE));
|
||||
return strip_newlines().trim(Infra::ASCII_WHITESPACE);
|
||||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#text-(type=text)-state-and-search-state-(type=search):value-sanitization-algorithm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue