mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
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.
This commit is contained in:
parent
8a8c06ac7b
commit
3fe28e380c
1 changed files with 21 additions and 8 deletions
|
@ -399,15 +399,28 @@ impl PropertyDeclarationBlock {
|
||||||
importance: Importance,
|
importance: Importance,
|
||||||
source: DeclarationSource,
|
source: DeclarationSource,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let all_shorthand_len = match drain.all_shorthand {
|
match source {
|
||||||
AllShorthand::NotSet => 0,
|
DeclarationSource::Parsing => {
|
||||||
AllShorthand::CSSWideKeyword(_) |
|
let all_shorthand_len = match drain.all_shorthand {
|
||||||
AllShorthand::WithVariables(_) => ShorthandId::All.longhands().len()
|
AllShorthand::NotSet => 0,
|
||||||
};
|
AllShorthand::CSSWideKeyword(_) |
|
||||||
let push_calls_count = drain.declarations.len() + all_shorthand_len;
|
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.
|
// With deduplication the actual length increase may be less than this.
|
||||||
self.declarations.reserve(push_calls_count);
|
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;
|
let mut changed = false;
|
||||||
for decl in &mut drain.declarations {
|
for decl in &mut drain.declarations {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue