Use Boxed slices for Empty and MozAny.

MozReview-Commit-ID: CmVK3u0vYn0
This commit is contained in:
Bobby Holley 2017-04-20 12:02:41 -07:00
parent 6d66ec5e11
commit cf06e2bf1e
2 changed files with 7 additions and 7 deletions

View file

@ -237,7 +237,7 @@ impl<Impl: SelectorImpl> SelectorMethods for SimpleSelector<Impl> {
match *self {
Negation(ref negated) => {
for selector in negated {
for selector in negated.iter() {
if !selector.visit(visitor) {
return false;
}
@ -453,7 +453,7 @@ pub enum SimpleSelector<Impl: SelectorImpl> {
AttrSuffixNeverMatch(AttrSelector<Impl>, Impl::AttrValue), // empty value
// Pseudo-classes
Negation(Vec<ComplexSelector<Impl>>),
Negation(Box<[ComplexSelector<Impl>]>),
FirstChild, LastChild, OnlyChild,
Root,
Empty,
@ -1163,7 +1163,7 @@ fn parse_negation<P, Impl>(parser: &P,
where P: Parser<Impl=Impl>, Impl: SelectorImpl
{
input.parse_comma_separated(|input| ComplexSelector::parse(parser, input))
.map(SimpleSelector::Negation)
.map(|v| SimpleSelector::Negation(v.into_boxed_slice()))
}
/// simple_selector_sequence
@ -1681,7 +1681,7 @@ pub mod tests {
ComplexSelector::from_vec(vec!(
SimpleSelector::ID(DummyAtom::from("provel")),
SimpleSelector::Class(DummyAtom::from("old")),
)))
))).into_boxed_slice()
))),
pseudo_element: None,
specificity: specificity(1, 1, 0),

View file

@ -217,7 +217,7 @@ macro_rules! pseudo_class_name {
///
/// TODO(emilio): We disallow combinators and pseudos here, so we
/// should use SimpleSelector instead
MozAny(Vec<ComplexSelector<SelectorImpl>>),
MozAny(Box<[ComplexSelector<SelectorImpl>]>),
}
}
}
@ -266,7 +266,7 @@ impl SelectorMethods for NonTSPseudoClass {
where V: SelectorVisitor<Impl = Self::Impl>,
{
if let NonTSPseudoClass::MozAny(ref selectors) = *self {
for selector in selectors {
for selector in selectors.iter() {
if !selector.visit(visitor) {
return false;
}
@ -401,7 +401,7 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> {
if selectors.iter().flat_map(|x| x.iter_raw()).any(|s| s.is_combinator()) {
return Err(())
}
NonTSPseudoClass::MozAny(selectors)
NonTSPseudoClass::MozAny(selectors.into_boxed_slice())
}
_ => return Err(())
}