Skip to content

Commit

Permalink
Bug 1663618 - Speed up custom property diffing. r=boris
Browse files Browse the repository at this point in the history
When entering or leaving fullscreen in youtube, we spend most of the
restyle time diffing custom properties, under IndexMap::eq.

Turns out that IndexMap equality is not order-aware, and thus you
actually need to make a hashmap lookup for each entry in the map, which
is unnecessarily inefficient.

Instead, just compare the iterators.

See indexmap-rs/indexmap#153.

Differential Revision: https://phabricator.services.mozilla.com/D89434

UltraBlame original commit: d46a20917d66d3c7fc9ada2204eae0af92365e08
  • Loading branch information
marco-c committed Sep 16, 2020
1 parent 45d2715 commit 5e7879e
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 14 deletions.
9 changes: 2 additions & 7 deletions servo/components/style/gecko/restyle_damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,12 @@ if
reset_only
&
&
!
old_style
.
custom_properties
custom_properties_equal
(
)
!
=
new_style
.
custom_properties
(
)
{
any_style_changed
Expand Down
110 changes: 110 additions & 0 deletions servo/components/style/properties/properties.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16050,6 +16050,116 @@ as_ref
(
)
}
pub
fn
custom_properties_equal
(
&
self
other
:
&
Self
)
-
>
bool
{
match
(
self
.
custom_properties
(
)
other
.
custom_properties
(
)
)
{
(
Some
(
l
)
Some
(
r
)
)
=
>
{
l
.
len
(
)
=
=
r
.
len
(
)
&
&
l
.
iter
(
)
.
zip
(
r
.
iter
(
)
)
.
all
(
|
(
(
k1
v1
)
(
k2
v2
)
)
|
k1
=
=
k2
&
&
v1
=
=
v2
)
}
(
None
None
)
=
>
true
_
=
>
false
}
}
%
for
prop
Expand Down
9 changes: 2 additions & 7 deletions servo/components/style/servo/restyle_damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,17 +1066,12 @@ REPAINT
)
;
if
!
old
.
custom_properties
custom_properties_equal
(
)
!
=
new
.
custom_properties
(
)
{
damage
Expand Down

0 comments on commit 5e7879e

Please sign in to comment.