style: Rework how precomputed pseudo stuff works, to avoid malloc/free churn.

This showed up in a few profiles, and was an easy improvement.

MozReview-Commit-ID: HVqATaSB2Ak
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-08-07 12:16:50 +02:00
parent 48b7e6d27c
commit 64a96ce21c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 50 additions and 67 deletions

View file

@ -201,29 +201,6 @@ impl SelectorMap<Rule> {
|block| (block.specificity, block.source_order()));
}
/// Append to `rule_list` all universal Rules (rules with selector `*|*`) in
/// `self` sorted by specificity and source order.
pub fn get_universal_rules(&self,
cascade_level: CascadeLevel)
-> Vec<ApplicableDeclarationBlock> {
debug_assert!(!cascade_level.is_important());
if self.is_empty() {
return vec![];
}
let mut rules_list = vec![];
for rule in self.other.iter() {
if rule.selector.is_universal() {
rules_list.push(rule.to_applicable_declaration_block(cascade_level))
}
}
sort_by_key(&mut rules_list,
|block| (block.specificity, block.source_order()));
rules_list
}
/// Adds rules in `rules` that match `element` to the `matching_rules` list.
fn get_matching_rules<E, V, F>(element: &E,
rules: &[Rule],