servo: Merge #18396 - Reduce duplication in generated ServoComputedData::to_declaration_block (from jdm:codesize); r=emilio
authorJosh Matthews <josh@joshmatthews.net>
Wed, 06 Sep 2017 13:44:30 -0500
changeset 660382 3f4037fca66795fda968e20fb2b164320f5a357b
parent 660381 53286dcc59e9455e53222cc49ae13883982d6224
child 660383 60a28a7012ede9f22b45174c8b730a89c640636b
push id78390
push userbmo:emilio@crisal.io
push dateWed, 06 Sep 2017 23:04:15 +0000
reviewersemilio
milestone57.0a1
servo: Merge #18396 - Reduce duplication in generated ServoComputedData::to_declaration_block (from jdm:codesize); r=emilio This reduces the size of the code in libXUL by 23.4k according to bloaty. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors Source-Repo: https://github.com/servo/servo Source-Revision: af587e5f84cabaa9fd500438adb1d24218b898e2
servo/components/style/properties/gecko.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -337,39 +337,37 @@ impl ComputedValuesInner {
         !self.get_box().gecko.mBinding.mPtr.mRawPtr.is_null()
     }
 
     // FIXME(bholley): Implement this properly.
     #[inline]
     pub fn is_multicol(&self) -> bool { false }
 
     pub fn to_declaration_block(&self, property: PropertyDeclarationId) -> PropertyDeclarationBlock {
-        match property {
+        let value = match property {
             % for prop in data.longhands:
                 % if prop.animatable:
                     PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => {
-                         PropertyDeclarationBlock::with_one(
-                            PropertyDeclaration::${prop.camel_case}(
-                                % if prop.boxed:
-                                    Box::new(
-                                % endif
-                                longhands::${prop.ident}::SpecifiedValue::from_computed_value(
-                                  &self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
-                                % if prop.boxed:
-                                    )
-                                % endif
-                            ),
-                            Importance::Normal
+                        PropertyDeclaration::${prop.camel_case}(
+                            % if prop.boxed:
+                                Box::new(
+                            % endif
+                            longhands::${prop.ident}::SpecifiedValue::from_computed_value(
+                              &self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
+                            % if prop.boxed:
+                                )
+                            % endif
                         )
                     },
                 % endif
             % endfor
             PropertyDeclarationId::Custom(_name) => unimplemented!(),
             _ => unimplemented!()
-        }
+        };
+        PropertyDeclarationBlock::with_one(value, Importance::Normal)
     }
 }
 
 <%def name="declare_style_struct(style_struct)">
 pub use ::gecko_bindings::structs::mozilla::Gecko${style_struct.gecko_name} as ${style_struct.gecko_struct_name};
 impl ${style_struct.gecko_struct_name} {
     pub fn gecko(&self) -> &${style_struct.gecko_ffi_name} {
         &self.gecko