From 2908c6a266aa61535c12f1b332cb5e0985dad88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 14 Sep 2017 10:00:00 +0200 Subject: [PATCH] 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. --- components/style/traversal.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 2823abddec8..a5ddb33749e 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -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 }