mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Early return from replace_data() if data didn't change
Allows us to avoid invalidating layout when CharacterData didn't change. Results in visible improvement on Discord that continuously invokes this function with the same data, which previously resulted in relayout on every frame.
This commit is contained in:
parent
0f3665e64e
commit
036327332f
|
|
@ -95,6 +95,12 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
|
|||
full_data.extend(inserted_data);
|
||||
full_data.append(after_data.data(), after_data.length_in_code_units());
|
||||
Utf16View full_view { full_data };
|
||||
|
||||
// OPTIMIZATION: Skip subsequent steps if the data didn't change.
|
||||
if (utf16_view == full_view) {
|
||||
return {};
|
||||
}
|
||||
|
||||
m_data = MUST(full_view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
|
||||
// 8. For each live range whose start node is node and start offset is greater than offset but less than or equal to offset plus count, set its start offset to offset.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user