Skip to content

Commit

Permalink
style: Don't use SmallVec::into_iter to move into another vector.
Browse files Browse the repository at this point in the history
See bug 1374848 for why.
  • Loading branch information
emilio committed Jun 20, 2017
1 parent ce9cd80 commit 1572bd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/style/invalidation/element/invalidator.rs
Expand Up @@ -492,7 +492,7 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
}
}

sibling_invalidations.extend(new_sibling_invalidations.into_iter());
sibling_invalidations.extend(new_sibling_invalidations.drain());
invalidated_self
}

Expand Down
17 changes: 10 additions & 7 deletions components/style/rule_tree/mod.rs
Expand Up @@ -218,19 +218,19 @@ impl RuleTree {
// followed by any transition rule.
//

for source in important_author.into_iter() {
for source in important_author.drain() {
current = current.ensure_child(self.root.downgrade(), source, AuthorImportant);
}

if let Some(source) = important_style_attr {
current = current.ensure_child(self.root.downgrade(), source, StyleAttributeImportant);
}

for source in important_user.into_iter() {
for source in important_user.drain() {
current = current.ensure_child(self.root.downgrade(), source, UserImportant);
}

for source in important_ua.into_iter() {
for source in important_ua.drain() {
current = current.ensure_child(self.root.downgrade(), source, UAImportant);
}

Expand Down Expand Up @@ -302,7 +302,7 @@ impl RuleTree {
let mut current = path.clone();

// First walk up until the first less-or-equally specific rule.
let mut children = vec![];
let mut children = SmallVec::<[_; 10]>::new();
while current.get().level > level {
children.push((current.get().source.clone(), current.get().level));
current = current.parent().unwrap().clone();
Expand Down Expand Up @@ -369,7 +369,9 @@ impl RuleTree {

// Now the rule is in the relevant place, push the children as
// necessary.
Some(self.insert_ordered_rules_from(current, children.into_iter().rev()))
let rule =
self.insert_ordered_rules_from(current, children.drain().rev());
Some(rule)
}

/// Returns new rule nodes without Transitions level rule.
Expand All @@ -392,15 +394,16 @@ impl RuleTree {
let iter = path.self_and_ancestors().take_while(
|node| node.cascade_level() >= CascadeLevel::SMILOverride);
let mut last = path;
let mut children = vec![];
let mut children = SmallVec::<[_; 10]>::new();
for node in iter {
if !node.cascade_level().is_animation() {
children.push((node.get().source.clone(), node.cascade_level()));
}
last = node;
}

self.insert_ordered_rules_from(last.parent().unwrap().clone(), children.into_iter().rev())
let rule = self.insert_ordered_rules_from(last.parent().unwrap().clone(), children.drain().rev());
rule
}
}

Expand Down

0 comments on commit 1572bd0

Please sign in to comment.