Avoid pointer-chasing to check whether there are any declarations.

This commit is contained in:
Bobby Holley 2017-04-20 21:50:10 -07:00
parent 97c14f05df
commit 1d6763c8e9
2 changed files with 69 additions and 43 deletions

View file

@ -34,12 +34,11 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
let guard = shared_lock.read();
let rule = locked.read_with(&guard);
rule.selectors.0.iter().map(|s| {
Rule {
selector: s.inner.clone(),
style_rule: locked.clone(),
specificity: s.specificity,
source_order: i,
}
Rule::new(&guard,
s.inner.clone(),
locked.clone(),
i,
s.specificity)
}).collect()
}).collect(), shared_lock)
}
@ -62,7 +61,7 @@ fn test_rule_ordering_same_specificity() {
let (rules_list, _) = get_mock_rules(&["a.intro", "img.sidebar"]);
let a = &rules_list[0][0];
let b = &rules_list[1][0];
assert!((a.specificity, a.source_order) < ((b.specificity, b.source_order)),
assert!((a.specificity(), a.source_order) < ((b.specificity(), b.source_order)),
"The rule that comes later should win.");
}