From 3afab1400a10d2509e1dbead177c3126403e88ee Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Sat, 10 Jun 2017 10:49:08 -0700 Subject: [PATCH] Make source_order u32 and shrink Rule. MozReview-Commit-ID: AKNTZZqke1O --- components/style/stylist.rs | 10 +++++----- tests/unit/style/stylist.rs | 2 +- tests/unit/stylo/size_of.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 497b51732d7..5db9b14c8f2 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -121,7 +121,7 @@ pub struct Stylist { /// A monotonically increasing counter to represent the order on which a /// style rule appears in a stylesheet, needed to sort them by source order. - rules_source_order: usize, + rules_source_order: u32, /// Selector dependencies used to compute restyle hints. dependencies: DependencySet, @@ -1497,11 +1497,11 @@ pub struct Rule { /// The ancestor hashes associated with the selector. #[cfg_attr(feature = "servo", ignore_heap_size_of = "No heap data")] pub hashes: AncestorHashes, + /// The source order this style rule appears in. + pub source_order: u32, /// The actual style rule. #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] pub style_rule: Arc>, - /// The source order this style rule appears in. - pub source_order: usize, } impl SelectorMapEntry for Rule { @@ -1537,7 +1537,7 @@ impl Rule { pub fn new(selector: Selector, hashes: AncestorHashes, style_rule: Arc>, - source_order: usize) + source_order: u32) -> Self { Rule { @@ -1561,7 +1561,7 @@ pub struct ApplicableDeclarationBlock { #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] pub source: StyleSource, /// The source order of this block. - pub source_order: usize, + pub source_order: u32, /// The specificity of the selector this block is represented by. pub specificity: u32, /// The cascade level this applicable declaration block is in. diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs index 17faaddd04a..ee4ac0b53f7 100644 --- a/tests/unit/style/stylist.rs +++ b/tests/unit/style/stylist.rs @@ -45,7 +45,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec>, SharedRwLock) { let guard = shared_lock.read(); let rule = locked.read_with(&guard); rule.selectors.0.iter().map(|s| { - Rule::new(s.selector.clone(), s.hashes.clone(), locked.clone(), i) + Rule::new(s.selector.clone(), s.hashes.clone(), locked.clone(), i as u32) }).collect() }).collect(), shared_lock) } diff --git a/tests/unit/stylo/size_of.rs b/tests/unit/stylo/size_of.rs index 9bf499ea844..af23e38a43e 100644 --- a/tests/unit/stylo/size_of.rs +++ b/tests/unit/stylo/size_of.rs @@ -27,7 +27,7 @@ fn size_of_selectors_dummy_types() { // The size of this is critical to performance on the bloom-basic microbenchmark. // When iterating over a large Rule array, we want to be able to fast-reject // selectors (with the inline hashes) with as few cache misses as possible. -size_of_test!(test_size_of_rule, style::stylist::Rule, 40); +size_of_test!(test_size_of_rule, style::stylist::Rule, 32); size_of_test!(test_size_of_option_arc_cv, Option>, 8); size_of_test!(test_size_of_option_rule_node, Option, 8);