mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Remove the peekable() overhead in font-family parsing.
This commit is contained in:
parent
449683565f
commit
be51f4fb8f
2 changed files with 6 additions and 8 deletions
|
@ -191,11 +191,9 @@ pub mod font_family {
|
|||
/// <familiy-name> = <string> | [ <ident>+ ]
|
||||
/// TODO: <generic-familiy>
|
||||
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
|
||||
// XXX Using peekable() for compat with parsing of the 'font' shorthand.
|
||||
from_iter(input.skip_whitespace().peekable())
|
||||
from_iter(input.skip_whitespace())
|
||||
}
|
||||
type Iter<'self> = iterator::Peekable<&'self ComponentValue, SkipWhitespaceIterator<'self>>;
|
||||
pub fn from_iter(mut iter: Iter) -> Option<SpecifiedValue> {
|
||||
pub fn from_iter<'a>(mut iter: SkipWhitespaceIterator<'a>) -> Option<SpecifiedValue> {
|
||||
let mut result = ~[];
|
||||
macro_rules! add(
|
||||
($value: expr) => {
|
||||
|
|
|
@ -245,10 +245,10 @@ shorthand!(font [
|
|||
if size.is_none() || (count(&style) + count(&weight) + count(&variant) + nb_normals) > 3 {
|
||||
return None
|
||||
}
|
||||
let mut iter = iter.peekable();
|
||||
match iter.peek() {
|
||||
Some(& &Delim('/')) => {
|
||||
iter.next();
|
||||
let mut copied_iter = iter.clone();
|
||||
match copied_iter.next() {
|
||||
Some(&Delim('/')) => {
|
||||
iter = copied_iter;
|
||||
line_height = match iter.next() {
|
||||
Some(v) => line_height::from_component_value(v),
|
||||
_ => return None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue