Remove the peekable() overhead in font-family parsing.

This commit is contained in:
Simon Sapin 2013-08-14 00:30:31 +01:00
parent 449683565f
commit be51f4fb8f
2 changed files with 6 additions and 8 deletions

View file

@ -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) => {

View file

@ -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,