mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 17:27:51 +03:00
LibJS: Skip redundant UTF-8 validation in rope string resolution
When resolving a rope, we've already taken care to resolve it to a UTF-8 byte stream. There's no need to do a separate pass just for validating the data again. This was noticeable in some profiles. I made a simple microbenchmark that gets a 30% speed-up: ("x" + "y".repeat(100_000_000)).trimStart()
This commit is contained in:
parent
3c039903fb
commit
0ad4be3d78
Notes:
sideshowbarker
2024-07-17 02:29:45 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0ad4be3d78 Pull-request: https://github.com/SerenityOS/serenity/pull/22496 Reviewed-by: https://github.com/LucasChollet
@ -348,7 +348,8 @@ void PrimitiveString::resolve_rope_if_needed(EncodingPreference preference) cons
|
||||
previous = current;
|
||||
}
|
||||
|
||||
m_utf8_string = MUST(builder.to_string());
|
||||
// NOTE: We've already produced valid UTF-8 above, so there's no need for additional validation.
|
||||
m_utf8_string = builder.to_string_without_validation();
|
||||
m_is_rope = false;
|
||||
m_lhs = nullptr;
|
||||
m_rhs = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user