@@ -1094,17 +1094,32 @@ impl PropertyDeclaration {
1094
1094
/// Given a property declaration, return the property declaration id.
1095
1095
pub fn id( & self ) -> PropertyDeclarationId {
1096
1096
match * self {
1097
+ PropertyDeclaration :: Custom ( ref name, _) => {
1098
+ return PropertyDeclarationId : : Custom ( name)
1099
+ }
1100
+ PropertyDeclaration :: CSSWideKeyword ( id, _) |
1101
+ PropertyDeclaration : : WithVariables ( id, _) => {
1102
+ return PropertyDeclarationId :: Longhand ( id)
1103
+ }
1104
+ _ => { }
1105
+ }
1106
+ let longhand_id = match * self {
1097
1107
% for property in data. longhands:
1098
1108
PropertyDeclaration :: ${ property. camel_case } ( ..) => {
1099
- PropertyDeclarationId :: Longhand ( LonghandId :: ${ property. camel_case } )
1109
+ LonghandId :: ${ property. camel_case }
1100
1110
}
1101
1111
% endfor
1102
- PropertyDeclaration :: CSSWideKeyword ( id, _) => PropertyDeclarationId :: Longhand ( id) ,
1103
- PropertyDeclaration :: WithVariables ( id, _) => PropertyDeclarationId :: Longhand ( id) ,
1104
- PropertyDeclaration :: Custom ( ref name, _) => {
1105
- PropertyDeclarationId :: Custom ( name)
1112
+ PropertyDeclaration :: CSSWideKeyword ( ..) |
1113
+ PropertyDeclaration :: WithVariables ( ..) |
1114
+ PropertyDeclaration :: Custom ( ..) => {
1115
+ debug_assert ! ( false , "unreachable" ) ;
1116
+ // This value is never used, but having an expression of the same "shape"
1117
+ // as for other variants helps the optimizer compile this `match` expression
1118
+ // to a lookup table.
1119
+ LonghandId :: BackgroundColor
1106
1120
}
1107
- }
1121
+ } ;
1122
+ PropertyDeclarationId :: Longhand ( longhand_id)
1108
1123
}
1109
1124
1110
1125
fn with_variables_from_shorthand( & self , shorthand: ShorthandId ) -> Option < & str> {
0 commit comments