mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Auto merge of #18281 - emilio:more-parse-dumbness, r=jdm
style: Avoid scanning the longhand id twice in the fast path of PropertyDeclarationBlock::parse_common This makes the overhead of this function much lower according to `perf`. And in general makes sense, removing overhead from the fast path. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18281) <!-- Reviewable:end -->
This commit is contained in:
commit
bd9cf3ce98
1 changed files with 7 additions and 5 deletions
|
@ -397,12 +397,14 @@ impl PropertyDeclarationBlock {
|
||||||
importance: Importance,
|
importance: Importance,
|
||||||
overwrite_more_important_and_reuse_slot: bool
|
overwrite_more_important_and_reuse_slot: bool
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let definitely_new = if let PropertyDeclarationId::Longhand(id) = declaration.id() {
|
let longhand_id = match declaration.id() {
|
||||||
!self.longhands.contains(id)
|
PropertyDeclarationId::Longhand(id) => Some(id),
|
||||||
} else {
|
PropertyDeclarationId::Custom(..) => None,
|
||||||
false // For custom properties, always scan
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let definitely_new = longhand_id.map_or(false, |id| {
|
||||||
|
!self.longhands.contains(id)
|
||||||
|
});
|
||||||
|
|
||||||
if !definitely_new {
|
if !definitely_new {
|
||||||
let mut index_to_remove = None;
|
let mut index_to_remove = None;
|
||||||
|
@ -444,7 +446,7 @@ impl PropertyDeclarationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let PropertyDeclarationId::Longhand(id) = declaration.id() {
|
if let Some(id) = longhand_id {
|
||||||
self.longhands.insert(id);
|
self.longhands.insert(id);
|
||||||
}
|
}
|
||||||
self.declarations.push((declaration, importance));
|
self.declarations.push((declaration, importance));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue