mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Eliminate redundant parse_selector.
MozReview-Commit-ID: 6eBVgT9ri5Q
This commit is contained in:
parent
27568de567
commit
442211723c
1 changed files with 5 additions and 17 deletions
|
@ -921,29 +921,17 @@ fn complex_selector_specificity<Impl>(mut iter: SelectorIter<Impl>)
|
||||||
specificity
|
specificity
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build up a Selector.
|
|
||||||
/// selector : simple_selector_sequence [ combinator simple_selector_sequence ]* ;
|
|
||||||
///
|
|
||||||
/// `Err` means invalid selector.
|
|
||||||
fn parse_selector<P, Impl>(parser: &P, input: &mut CssParser) -> Result<Selector<Impl>, ()>
|
|
||||||
where P: Parser<Impl=Impl>, Impl: SelectorImpl
|
|
||||||
{
|
|
||||||
let selector = parse_complex_selector(parser, input)?;
|
|
||||||
Ok(selector)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// We make this large because the result of parsing a selector is fed into a new
|
/// We make this large because the result of parsing a selector is fed into a new
|
||||||
/// Arc-ed allocation, so any spilled vec would be a wasted allocation. Also,
|
/// Arc-ed allocation, so any spilled vec would be a wasted allocation. Also,
|
||||||
/// Components are large enough that we don't have much cache locality benefit
|
/// Components are large enough that we don't have much cache locality benefit
|
||||||
/// from reserving stack space for fewer of them.
|
/// from reserving stack space for fewer of them.
|
||||||
type ParseVec<Impl> = SmallVec<[Component<Impl>; 32]>;
|
type ParseVec<Impl> = SmallVec<[Component<Impl>; 32]>;
|
||||||
|
|
||||||
/// Parses a complex selector, including any pseudo-element.
|
/// Build up a Selector.
|
||||||
|
/// selector : simple_selector_sequence [ combinator simple_selector_sequence ]* ;
|
||||||
///
|
///
|
||||||
/// For now, it always forces the pseudo-element to be at the end of the
|
/// `Err` means invalid selector.
|
||||||
/// selector, and the boolean represents whether the last thing parsed was a
|
fn parse_selector<P, Impl>(
|
||||||
/// pseudo-element.
|
|
||||||
fn parse_complex_selector<P, Impl>(
|
|
||||||
parser: &P,
|
parser: &P,
|
||||||
input: &mut CssParser)
|
input: &mut CssParser)
|
||||||
-> Result<Selector<Impl>, ()>
|
-> Result<Selector<Impl>, ()>
|
||||||
|
@ -1012,7 +1000,7 @@ impl<Impl: SelectorImpl> Selector<Impl> {
|
||||||
pub fn parse<P>(parser: &P, input: &mut CssParser) -> Result<Self, ()>
|
pub fn parse<P>(parser: &P, input: &mut CssParser) -> Result<Self, ()>
|
||||||
where P: Parser<Impl=Impl>
|
where P: Parser<Impl=Impl>
|
||||||
{
|
{
|
||||||
let selector = parse_complex_selector(parser, input)?;
|
let selector = parse_selector(parser, input)?;
|
||||||
if selector.has_pseudo_element() {
|
if selector.has_pseudo_element() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue