mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02: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:
committed by
Jelle Raaijmakers
parent
0efa98a57a
commit
2dc0a3b3ce
Notes:
github-actions[bot]
2025-08-05 13:15:06 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/2dc0a3b3cea Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5720 Reviewed-by: https://github.com/gmta ✅
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user