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:
Emilio Cobos Álvarez 2018-06-04 21:08:35 +02:00
parent c6e43c0329
commit 7529788375
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -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.