From 0e8b1853a716d320db44169c727e48d68c72b02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 3 Aug 2019 10:05:14 +0000 Subject: [PATCH] style: Expand and simplify a macro that's not very useful. Skip whitespace upfront rather than on each individual branch. The only difference in behavior is that we would've consumed some extra whitespace in the error case, but I don't think that matters at all. We were consuming some extra whitespace as well after the close path command for example, which wasn't parsing anything. Differential Revision: https://phabricator.services.mozilla.com/D40539 --- components/style/values/specified/svg_path.rs | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/components/style/values/specified/svg_path.rs b/components/style/values/specified/svg_path.rs index 7d40cae1fcf..4f49029b51e 100644 --- a/components/style/values/specified/svg_path.rs +++ b/components/style/values/specified/svg_path.rs @@ -631,30 +631,20 @@ impl<'a> PathParser<'a> { } else { IsAbsolute::No }; - macro_rules! parse_command { - ( $($($p:pat)|+ => $parse_func:ident,)* ) => { - match command { - $( - $($p)|+ => { - skip_wsp(&mut self.chars); - self.$parse_func(abs)?; - }, - )* - _ => return Err(()), - } - } - } - parse_command!( - b'Z' | b'z' => parse_closepath, - b'L' | b'l' => parse_lineto, - b'H' | b'h' => parse_h_lineto, - b'V' | b'v' => parse_v_lineto, - b'C' | b'c' => parse_curveto, - b'S' | b's' => parse_smooth_curveto, - b'Q' | b'q' => parse_quadratic_bezier_curveto, - b'T' | b't' => parse_smooth_quadratic_bezier_curveto, - b'A' | b'a' => parse_elliptical_arc, - ); + + skip_wsp(&mut self.chars); + match command { + b'Z' | b'z' => self.parse_closepath(), + b'L' | b'l' => self.parse_lineto(abs), + b'H' | b'h' => self.parse_h_lineto(abs), + b'V' | b'v' => self.parse_v_lineto(abs), + b'C' | b'c' => self.parse_curveto(abs), + b'S' | b's' => self.parse_smooth_curveto(abs), + b'Q' | b'q' => self.parse_quadratic_bezier_curveto(abs), + b'T' | b't' => self.parse_smooth_quadratic_bezier_curveto(abs), + b'A' | b'a' => self.parse_elliptical_arc(abs), + _ => return Err(()), + }?; } Ok(()) } @@ -688,7 +678,7 @@ impl<'a> PathParser<'a> { } /// Parse "closepath" command. - fn parse_closepath(&mut self, _absolute: IsAbsolute) -> Result<(), ()> { + fn parse_closepath(&mut self) -> Result<(), ()> { self.path.push(PathCommand::ClosePath); Ok(()) }