Bug 1491622 - Make LonghandId::flags an indexing operation. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 18 Sep 2018 09:15:12 +0000
changeset 495394 3ba37496274abb940d4b98df7e8df2209601af5a
parent 495393 90d22ac1a1ebe65e3614740be94f0650bf8cbd61
child 495395 12202cbf73b7b2786dcc914c782d6aba44a542e6
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1491622
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1491622 - Make LonghandId::flags an indexing operation. r=xidorn I always see a bunch of time in our profiles in the iterator over the declarations, this ensures it's not something dumb. I suspect it's just a bunch of cache misses from walking the rule tree but in any case this is consistent with the other getters we have and such. Differential Revision: https://phabricator.services.mozilla.com/D5971
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -1108,26 +1108,29 @@ impl LonghandId {
             None,
             % endif
             % endfor
         ];
         LOGICAL_GROUPS[*self as usize]
     }
 
     /// Returns PropertyFlags for given longhand property.
-    pub fn flags(&self) -> PropertyFlags {
-        match *self {
+    #[inline(always)]
+    pub fn flags(self) -> PropertyFlags {
+        // TODO(emilio): This can be simplified further as Rust gains more
+        // constant expression support.
+        const FLAGS: [u8; ${len(data.longhands)}] = [
             % for property in data.longhands:
-                LonghandId::${property.camel_case} =>
-                    % for flag in property.flags:
-                        PropertyFlags::${flag} |
-                    % endfor
-                    PropertyFlags::empty(),
+                % for flag in property.flags:
+                    PropertyFlags::${flag}.bits |
+                % endfor
+                0,
             % endfor
-        }
+        ];
+        PropertyFlags::from_bits_truncate(FLAGS[self as usize])
     }
 
     /// Only a few properties are allowed to depend on the visited state of
     /// links. When cascading visited styles, we can save time by only
     /// processing these properties.
     fn is_visited_dependent(&self) -> bool {
         matches!(*self,
             % if product == "gecko":