Skip to content

Commit

Permalink
Auto merge of #18293 - emilio:selector-map-box, r=SimonSapin
Browse files Browse the repository at this point in the history
style: Box the PerPseudo<SelectorMap>, so we don't waste a lot of space.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18293)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Aug 29, 2017
2 parents 1c4d0d2 + f28a62c commit 5062dc5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/style/stylist.rs
Expand Up @@ -257,7 +257,7 @@ impl DocumentCascadeData {
Some(pseudo) => {
origin_cascade_data
.pseudos_map
.get_or_insert_with(&pseudo.canonical(), SelectorMap::new)
.get_or_insert_with(&pseudo.canonical(), || Box::new(SelectorMap::new()))
.expect("Unexpected tree pseudo-element?")
}
};
Expand Down Expand Up @@ -1797,7 +1797,11 @@ struct CascadeData {

/// Rules from stylesheets at this `CascadeData`'s origin that correspond
/// to a given pseudo-element.
pseudos_map: PerPseudoElementMap<SelectorMap<Rule>>,
///
/// FIXME(emilio): There are a bunch of wasted entries here in practice.
/// Figure out a good way to do a `PerNonAnonBox` and `PerAnonBox` (for
/// `precomputed_values_for_pseudo`) without duplicating a lot of code.
pseudos_map: PerPseudoElementMap<Box<SelectorMap<Rule>>>,

/// A map with all the animations at this `CascadeData`'s origin, indexed
/// by name.
Expand Down Expand Up @@ -1875,7 +1879,7 @@ impl CascadeData {
#[inline]
fn borrow_for_pseudo(&self, pseudo: Option<&PseudoElement>) -> Option<&SelectorMap<Rule>> {
match pseudo {
Some(pseudo) => self.pseudos_map.get(&pseudo.canonical()),
Some(pseudo) => self.pseudos_map.get(&pseudo.canonical()).map(|p| &**p),
None => Some(&self.element_map),
}
}
Expand Down

0 comments on commit 5062dc5

Please sign in to comment.