mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
bc39f16b4b
commit
22da3c22a2
1 changed files with 11 additions and 8 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue