mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Make getting a property name explicitly an indexing operation.
The six milliseconds spent in Olli's profile make me thing this is not getting optimized and we expected. Also move it to NonCustomPropertyId, so it works for aliases properly too. Bug: 1466645 Reviewed-by: xidorn MozReview-Commit-ID: 4d76Z55ZBEH
This commit is contained in:
parent
c6e43c0329
commit
7529788375
1 changed files with 15 additions and 10 deletions
|
@ -428,6 +428,17 @@ impl NonCustomPropertyId {
|
|||
MAP[self.0]
|
||||
}
|
||||
|
||||
/// Get the property name.
|
||||
#[inline]
|
||||
fn name(self) -> &'static str {
|
||||
static MAP: [&'static str; ${len(data.longhands) + len(data.shorthands) + len(data.all_aliases())}] = [
|
||||
% for property in data.longhands + data.shorthands + data.all_aliases():
|
||||
"${property.name}",
|
||||
% endfor
|
||||
];
|
||||
MAP[self.0]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn enabled_for_all_content(self) -> bool {
|
||||
${static_non_custom_property_id_set(
|
||||
|
@ -860,12 +871,9 @@ impl fmt::Debug for LonghandId {
|
|||
|
||||
impl LonghandId {
|
||||
/// Get the name of this longhand property.
|
||||
#[inline]
|
||||
pub fn name(&self) -> &'static str {
|
||||
match *self {
|
||||
% for property in data.longhands:
|
||||
LonghandId::${property.camel_case} => "${property.name}",
|
||||
% endfor
|
||||
}
|
||||
NonCustomPropertyId::from(*self).name()
|
||||
}
|
||||
|
||||
/// Returns whether the longhand property is inherited by default.
|
||||
|
@ -1203,12 +1211,9 @@ impl ToCss for ShorthandId {
|
|||
|
||||
impl ShorthandId {
|
||||
/// Get the name for this shorthand property.
|
||||
#[inline]
|
||||
pub fn name(&self) -> &'static str {
|
||||
match *self {
|
||||
% for property in data.shorthands:
|
||||
ShorthandId::${property.camel_case} => "${property.name}",
|
||||
% endfor
|
||||
}
|
||||
NonCustomPropertyId::from(*self).name()
|
||||
}
|
||||
|
||||
/// Converts from a ShorthandId to an adequate nsCSSPropertyID.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue