From be51f4fb8f3bb894aa97bd60abce8345b18af45d Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 14 Aug 2013 00:30:31 +0100 Subject: [PATCH] Remove the peekable() overhead in font-family parsing. --- properties/longhands.rs | 6 ++---- properties/shorthands.rs | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/properties/longhands.rs b/properties/longhands.rs index 26aee4c2acb..64c859869a0 100644 --- a/properties/longhands.rs +++ b/properties/longhands.rs @@ -191,11 +191,9 @@ pub mod font_family { /// = | [ + ] /// TODO: pub fn parse(input: &[ComponentValue]) -> Option { - // 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 { + pub fn from_iter<'a>(mut iter: SkipWhitespaceIterator<'a>) -> Option { let mut result = ~[]; macro_rules! add( ($value: expr) => { diff --git a/properties/shorthands.rs b/properties/shorthands.rs index 014969b6b7f..b4358883813 100644 --- a/properties/shorthands.rs +++ b/properties/shorthands.rs @@ -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,