Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check for adjacent duplicates when accumulating revalidation selectors.
MozReview-Commit-ID: 4C8L5u1S1sL
  • Loading branch information
bholley committed Apr 27, 2017
1 parent 7e69cf8 commit 25832b9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion components/style/stylist.rs
Expand Up @@ -336,7 +336,20 @@ impl Stylist {
self.dependencies.note_selector(selector);

if needs_revalidation(selector) {
self.selectors_for_cache_revalidation.push(selector.inner.slice_to_first_ancestor_combinator());
// For revalidation, we can skip everything left of the first ancestor
// combinator.
let revalidation_sel = selector.inner.slice_to_first_ancestor_combinator();

// Because of the slicing we do above, we can often end up with
// adjacent duplicate selectors when we have selectors like
// body > foo, td > foo, th > foo, etc. Doing a check for
// adjacent duplicates here reduces the number of revalidation
// selectors for Gecko's UA sheet by 30%.
let duplicate = self.selectors_for_cache_revalidation.last()
.map_or(false, |x| x.complex == revalidation_sel.complex);
if !duplicate {
self.selectors_for_cache_revalidation.push(revalidation_sel);
}
}
}
}
Expand Down

0 comments on commit 25832b9

Please sign in to comment.