diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 22293688b3a..ece14613a75 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -6,7 +6,7 @@ use attr::{AttrSelectorWithNamespace, ParsedAttrSelectorOperation, AttrSelectorO use attr::{ParsedCaseSensitivity, SELECTOR_WHITESPACE, NamespaceConstraint}; use cssparser::{Token, Parser as CssParser, parse_nth, ToCss, serialize_identifier, CssStringWriter}; use precomputed_hash::PrecomputedHash; -use servo_arc::{Arc, HeaderSlice}; +use servo_arc::{Arc, HeaderWithLength, ThinArc}; use smallvec::SmallVec; use std::ascii::AsciiExt; use std::borrow::{Borrow, Cow}; @@ -324,15 +324,15 @@ impl SpecificityAndFlags { /// canonical iteration order is right-to-left (selector matching order). The /// iterators abstract over these details. #[derive(Clone, Eq, PartialEq)] -pub struct Selector(Arc]>>); +pub struct Selector(ThinArc>); impl Selector { pub fn specificity(&self) -> u32 { - self.0.header.specificity() + self.0.header.header.specificity() } pub fn has_pseudo_element(&self) -> bool { - self.0.header.has_pseudo_element() + self.0.header.header.has_pseudo_element() } pub fn pseudo_element(&self) -> Option<&Impl::PseudoElement> { @@ -396,8 +396,8 @@ impl Selector { /// Creates a Selector from a vec of Components. Used in tests. pub fn from_vec(vec: Vec>, specificity_and_flags: u32) -> Self { - let spec = SpecificityAndFlags(specificity_and_flags); - Selector(Arc::from_header_and_iter(spec, vec.into_iter())) + let header = HeaderWithLength::new(SpecificityAndFlags(specificity_and_flags), vec.len()); + Selector(Arc::into_thin(Arc::from_header_and_iter(header, vec.into_iter()))) } } @@ -1002,7 +1002,8 @@ fn parse_complex_selector( spec.0 |= HAS_PSEUDO_BIT; } - let complex = Selector(Arc::from_header_and_iter(spec, sequence.into_iter())); + let header = HeaderWithLength::new(spec, sequence.len()); + let complex = Selector(Arc::into_thin(Arc::from_header_and_iter(header, sequence.into_iter()))); Ok(complex) } diff --git a/tests/unit/stylo/size_of.rs b/tests/unit/stylo/size_of.rs index 0cdf3067210..3344a65c075 100644 --- a/tests/unit/stylo/size_of.rs +++ b/tests/unit/stylo/size_of.rs @@ -22,7 +22,7 @@ fn size_of_selectors_dummy_types() { // The size of this is critical to performance on the bloom-basic microbenchmark. // When iterating over a large Rule array, we want to be able to fast-reject // selectors (with the inline hashes) with as few cache misses as possible. -size_of_test!(test_size_of_rule, style::stylist::Rule, 48); +size_of_test!(test_size_of_rule, style::stylist::Rule, 40); size_of_test!(test_size_of_property_declaration, style::properties::PropertyDeclaration, 32);