From 5cc3093a753e0442ed20f733a89861747f0a0797 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 8 Jun 2017 14:26:30 -0700 Subject: [PATCH] servo: Merge #17242 - Reduce the size of ApplicableDeclarationBlock (from bzbarsky:smaller-decl-block); r=bholley The level is a u8, so on 64-bit it packs nicely after the u32 specificity. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1371297 - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: ca8961a93bd5dfb2680ed0cb73a5fcc0ce0f0fdb --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 50e8378984e0b24cde80ee88d52c0a58ab123cc5 --- servo/components/style/stylist.rs | 8 ++++---- servo/tests/unit/stylo/size_of.rs | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/servo/components/style/stylist.rs b/servo/components/style/stylist.rs index 0211f9b0e0a3..6374737f1570 100644 --- a/servo/components/style/stylist.rs +++ b/servo/components/style/stylist.rs @@ -1524,9 +1524,9 @@ impl Rule { -> ApplicableDeclarationBlock { ApplicableDeclarationBlock { source: StyleSource::Style(self.style_rule.clone()), - level: level, source_order: self.source_order, specificity: self.specificity(), + level: level, } } @@ -1557,12 +1557,12 @@ pub struct ApplicableDeclarationBlock { /// The style source, either a style rule, or a property declaration block. #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] pub source: StyleSource, - /// The cascade level this applicable declaration block is in. - pub level: CascadeLevel, /// The source order of this block. pub source_order: usize, /// The specificity of the selector this block is represented by. pub specificity: u32, + /// The cascade level this applicable declaration block is in. + pub level: CascadeLevel, } impl ApplicableDeclarationBlock { @@ -1574,9 +1574,9 @@ impl ApplicableDeclarationBlock { -> Self { ApplicableDeclarationBlock { source: StyleSource::Declarations(declarations), - level: level, source_order: 0, specificity: 0, + level: level, } } } diff --git a/servo/tests/unit/stylo/size_of.rs b/servo/tests/unit/stylo/size_of.rs index 31b6d70b32fb..9bf499ea844c 100644 --- a/servo/tests/unit/stylo/size_of.rs +++ b/servo/tests/unit/stylo/size_of.rs @@ -10,6 +10,7 @@ use style::data::{ComputedStyle, ElementData, ElementStyles}; use style::gecko::selector_parser as real; use style::properties::ComputedValues; use style::rule_tree::StrongRuleNode; +use style::stylist::ApplicableDeclarationBlock; #[test] fn size_of_selectors_dummy_types() { @@ -36,6 +37,8 @@ size_of_test!(test_size_of_element_data, ElementData, 56); size_of_test!(test_size_of_property_declaration, style::properties::PropertyDeclaration, 32); +size_of_test!(test_size_of_application_declaration_block, ApplicableDeclarationBlock, 32); + // This is huge, but we allocate it on the stack and then never move it, // we only pass `&mut SourcePropertyDeclaration` references around. size_of_test!(test_size_of_parsed_declaration, style::properties::SourcePropertyDeclaration, 704);