style: Make LonghandId::flags an indexing operation.

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
This commit is contained in:
Emilio Cobos Álvarez 2018-09-18 09:15:12 +00:00
parent bc39f16b4b
commit 22da3c22a2
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -1113,16 +1113,19 @@ impl LonghandId {
} }
/// Returns PropertyFlags for given longhand property. /// Returns PropertyFlags for given longhand property.
pub fn flags(&self) -> PropertyFlags { #[inline(always)]
match *self { 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: % for property in data.longhands:
LonghandId::${property.camel_case} => % for flag in property.flags:
% for flag in property.flags: PropertyFlags::${flag}.bits |
PropertyFlags::${flag} | % endfor
% endfor 0,
PropertyFlags::empty(),
% endfor % endfor
} ];
PropertyFlags::from_bits_truncate(FLAGS[self as usize])
} }
/// Only a few properties are allowed to depend on the visited state of /// Only a few properties are allowed to depend on the visited state of