style: Don't cache styles that got a cache hit.

This avoids doing wasted work, at least in the recascade case, and pretty likely
in the other as well.
This commit is contained in:
Emilio Cobos Álvarez 2017-09-14 10:00:00 +02:00
parent 9d671058df
commit 2908c6a266
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -678,14 +678,14 @@ where
resolver.resolve_style_with_default_parents()
};
context.thread_local
.sharing_cache
.insert_if_possible(
if !new_styles.primary.0.reused_via_rule_node {
context.thread_local.sharing_cache.insert_if_possible(
&element,
new_styles.primary.style(),
Some(&mut target),
traversal_data.current_dom_depth,
);
}
new_styles
}
@ -724,12 +724,15 @@ where
resolver.cascade_styles_with_default_parents(cascade_inputs)
};
context.thread_local.sharing_cache.insert_if_possible(
&element,
new_styles.primary.style(),
None,
traversal_data.current_dom_depth,
);
if !new_styles.primary.0.reused_via_rule_node {
context.thread_local.sharing_cache.insert_if_possible(
&element,
new_styles.primary.style(),
None,
traversal_data.current_dom_depth,
);
}
new_styles
}