mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #19530 - emilio:extend-not-much, r=jdm
style: Don't unconditionally extend() the declaration block vector. Since it appears in profiles when used from CSSOM, like the one in the bug mentioned in the comment. <!-- 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/19530) <!-- Reviewable:end -->
This commit is contained in:
commit
f8a87a76b2
1 changed files with 21 additions and 8 deletions
|
@ -399,15 +399,28 @@ impl PropertyDeclarationBlock {
|
|||
importance: Importance,
|
||||
source: DeclarationSource,
|
||||
) -> bool {
|
||||
let all_shorthand_len = match drain.all_shorthand {
|
||||
AllShorthand::NotSet => 0,
|
||||
AllShorthand::CSSWideKeyword(_) |
|
||||
AllShorthand::WithVariables(_) => ShorthandId::All.longhands().len()
|
||||
};
|
||||
let push_calls_count = drain.declarations.len() + all_shorthand_len;
|
||||
match source {
|
||||
DeclarationSource::Parsing => {
|
||||
let all_shorthand_len = match drain.all_shorthand {
|
||||
AllShorthand::NotSet => 0,
|
||||
AllShorthand::CSSWideKeyword(_) |
|
||||
AllShorthand::WithVariables(_) => ShorthandId::All.longhands().len()
|
||||
};
|
||||
let push_calls_count =
|
||||
drain.declarations.len() + all_shorthand_len;
|
||||
|
||||
// With deduplication the actual length increase may be less than this.
|
||||
self.declarations.reserve(push_calls_count);
|
||||
// With deduplication the actual length increase may be less than this.
|
||||
self.declarations.reserve(push_calls_count);
|
||||
}
|
||||
DeclarationSource::CssOm => {
|
||||
// Don't bother reserving space, since it's usually the case
|
||||
// that CSSOM just overrides properties and we don't need to use
|
||||
// more memory. See bug 1424346 for an example where this
|
||||
// matters.
|
||||
//
|
||||
// TODO: Would it be worth to call reserve() just if it's empty?
|
||||
}
|
||||
}
|
||||
|
||||
let mut changed = false;
|
||||
for decl in &mut drain.declarations {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue