mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +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>+ ]
|
/// <familiy-name> = <string> | [ <ident>+ ]
|
||||||
/// TODO: <generic-familiy>
|
/// TODO: <generic-familiy>
|
||||||
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
|
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
|
||||||
// XXX Using peekable() for compat with parsing of the 'font' shorthand.
|
from_iter(input.skip_whitespace())
|
||||||
from_iter(input.skip_whitespace().peekable())
|
|
||||||
}
|
}
|
||||||
type Iter<'self> = iterator::Peekable<&'self ComponentValue, SkipWhitespaceIterator<'self>>;
|
pub fn from_iter<'a>(mut iter: SkipWhitespaceIterator<'a>) -> Option<SpecifiedValue> {
|
||||||
pub fn from_iter(mut iter: Iter) -> Option<SpecifiedValue> {
|
|
||||||
let mut result = ~[];
|
let mut result = ~[];
|
||||||
macro_rules! add(
|
macro_rules! add(
|
||||||
($value: expr) => {
|
($value: expr) => {
|
||||||
|
|
|
@ -245,10 +245,10 @@ shorthand!(font [
|
||||||
if size.is_none() || (count(&style) + count(&weight) + count(&variant) + nb_normals) > 3 {
|
if size.is_none() || (count(&style) + count(&weight) + count(&variant) + nb_normals) > 3 {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
let mut iter = iter.peekable();
|
let mut copied_iter = iter.clone();
|
||||||
match iter.peek() {
|
match copied_iter.next() {
|
||||||
Some(& &Delim('/')) => {
|
Some(&Delim('/')) => {
|
||||||
iter.next();
|
iter = copied_iter;
|
||||||
line_height = match iter.next() {
|
line_height = match iter.next() {
|
||||||
Some(v) => line_height::from_component_value(v),
|
Some(v) => line_height::from_component_value(v),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue