mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use Vec::reserve in PropertyDeclarationBlock
This commit is contained in:
parent
d2be5239f5
commit
cb8f77891f
1 changed files with 10 additions and 0 deletions
|
@ -218,6 +218,16 @@ impl PropertyDeclarationBlock {
|
||||||
|
|
||||||
fn extend_common(&mut self, mut drain: SourcePropertyDeclarationDrain,
|
fn extend_common(&mut self, mut drain: SourcePropertyDeclarationDrain,
|
||||||
importance: Importance, overwrite_more_important: bool) -> bool {
|
importance: Importance, overwrite_more_important: bool) -> 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;
|
||||||
|
|
||||||
|
// With deduplication the actual length increase may be less than this.
|
||||||
|
self.declarations.reserve(push_calls_count);
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for decl in &mut drain.declarations {
|
for decl in &mut drain.declarations {
|
||||||
changed |= self.push_common(decl, importance, overwrite_more_important);
|
changed |= self.push_common(decl, importance, overwrite_more_important);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue