style: Massage the resolver code so it's cleaner and prevents the problem.

This way all the borrows stay in the sharing code, and prevents an extra borrow
on a cache hit, which is not a big deal but nice.
This commit is contained in:
Emilio Cobos Álvarez 2017-09-18 03:21:39 +02:00
parent 36fed07b1c
commit 891bc7d174
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
6 changed files with 119 additions and 119 deletions

View file

@ -421,7 +421,7 @@ where
let is_display_contents = primary_style.style().is_display_contents();
style = Some(primary_style.0.into());
style = Some(primary_style.style.0);
if !is_display_contents {
layout_parent_style = style.clone();
}
@ -659,9 +659,9 @@ where
// Now that our bloom filter is set up, try the style sharing
// cache.
match target.share_style_if_possible(context) {
Some(shareable_element) => {
Some(shared_styles) => {
context.thread_local.statistics.styles_shared += 1;
shareable_element.borrow_data().unwrap().share_styles()
shared_styles
}
None => {
context.thread_local.statistics.elements_matched += 1;
@ -738,7 +738,7 @@ where
// number of eventual styles, but would potentially miss out on various
// opportunities for skipping selector matching, which could hurt
// performance.
if !new_styles.primary.0.reused_via_rule_node {
if !new_styles.primary.reused_via_rule_node {
context.thread_local.sharing_cache.insert_if_possible(
&element,
&new_styles.primary,