mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00: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
1 changed files with 2 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue