diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-09-25 14:53:58 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-09-25 16:07:32 +0200 |
commit | 3067d2e320b915be52279acb93c68dd269d4b7ba (patch) | |
tree | 89db305405d1d04ad5fada7e160cbbb241851a4c | |
parent | d9cec56d712a69bc78f918abe1774f9007a0ec9a (diff) | |
download | servo-3067d2e320b915be52279acb93c68dd269d4b7ba.tar.gz servo-3067d2e320b915be52279acb93c68dd269d4b7ba.zip |
style: Early return in a couple of places to deindent some code.
MozReview-Commit-ID: 8hDAKZANOro
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
-rw-r--r-- | components/style/properties/longhand/inherited_svg.mako.rs | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 3742adb5f63..e9bf1cda65c 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -182,57 +182,57 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<SpecifiedValue,ParseError<'i>> { if let Ok(()) = input.try(|i| i.expect_ident_matching("normal")) { - Ok(SpecifiedValue(0)) - } else { - let mut value = 0; - // bitfield representing what we've seen so far - // bit 1 is fill, bit 2 is stroke, bit 3 is markers - let mut seen = 0; - let mut pos = 0; - - loop { - let result: Result<_, ParseError> = input.try(|i| { - try_match_ident_ignore_ascii_case! { i.expect_ident()?, - "fill" => Ok(FILL), - "stroke" => Ok(STROKE), - "markers" => Ok(MARKERS), - } - }); - - match result { - Ok(val) => { - if (seen & (1 << val)) != 0 { - // don't parse the same ident twice - return Err(StyleParseError::UnspecifiedError.into()) - } else { - value |= val << (pos * SHIFT); - seen |= 1 << val; - pos += 1; - } - } - Err(_) => break, + return Ok(SpecifiedValue(0)) + } + + let mut value = 0; + // bitfield representing what we've seen so far + // bit 1 is fill, bit 2 is stroke, bit 3 is markers + let mut seen = 0; + let mut pos = 0; + + loop { + let result: Result<_, ParseError> = input.try(|i| { + try_match_ident_ignore_ascii_case! { i.expect_ident()?, + "fill" => Ok(FILL), + "stroke" => Ok(STROKE), + "markers" => Ok(MARKERS), } - } + }); - if value == 0 { - // couldn't find any keyword - Err(StyleParseError::UnspecifiedError.into()) - } else { - // fill in rest - for i in pos..COUNT { - for paint in &ALL { - // if not seen, set bit at position, mark as seen - if (seen & (1 << paint)) == 0 { - seen |= 1 << paint; - value |= paint << (i * SHIFT); - break; - } + match result { + Ok(val) => { + if (seen & (1 << val)) != 0 { + // don't parse the same ident twice + return Err(StyleParseError::UnspecifiedError.into()) } + + value |= val << (pos * SHIFT); + seen |= 1 << val; + pos += 1; } + Err(_) => break, + } + } + + if value == 0 { + // couldn't find any keyword + return Err(StyleParseError::UnspecifiedError.into()) + } - Ok(SpecifiedValue(value)) + // fill in rest + for i in pos..COUNT { + for paint in &ALL { + // if not seen, set bit at position, mark as seen + if (seen & (1 << paint)) == 0 { + seen |= 1 << paint; + value |= paint << (i * SHIFT); + break; + } } } + + Ok(SpecifiedValue(value)) } impl ToCss for SpecifiedValue { |