mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use ThinArc in Selector.
MozReview-Commit-ID: Axvq0rbqA7Y
This commit is contained in:
parent
ce8d2a9208
commit
27568de567
2 changed files with 9 additions and 8 deletions
|
@ -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<Impl: SelectorImpl>(Arc<HeaderSlice<SpecificityAndFlags, [Component<Impl>]>>);
|
||||
pub struct Selector<Impl: SelectorImpl>(ThinArc<SpecificityAndFlags, Component<Impl>>);
|
||||
|
||||
impl<Impl: SelectorImpl> Selector<Impl> {
|
||||
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<Impl: SelectorImpl> Selector<Impl> {
|
|||
|
||||
/// Creates a Selector from a vec of Components. Used in tests.
|
||||
pub fn from_vec(vec: Vec<Component<Impl>>, 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<P, Impl>(
|
|||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue