servo: Merge #17443 - style: Don't use SmallVec::into_iter to move into another vector (from emilio:smallwat); r=SimonSapin

See bug 1374848 for why.

Source-Repo: https://github.com/servo/servo
Source-Revision: 6b99318f552c1561392208efd9030d0b4a6f91d1

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 27123c796e94135b62aae6b5669017cbdd5e3c49
This commit is contained in:
Emilio Cobos Álvarez 2017-06-22 00:14:38 -07:00
Родитель fda77ae953
Коммит 45787e3da4
2 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -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 invalidated_self
} }

Просмотреть файл

@ -218,7 +218,7 @@ impl RuleTree {
// followed by any transition rule. // 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); current = current.ensure_child(self.root.downgrade(), source, AuthorImportant);
} }
@ -226,11 +226,11 @@ impl RuleTree {
current = current.ensure_child(self.root.downgrade(), source, StyleAttributeImportant); 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); 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); current = current.ensure_child(self.root.downgrade(), source, UAImportant);
} }
@ -302,7 +302,7 @@ impl RuleTree {
let mut current = path.clone(); let mut current = path.clone();
// First walk up until the first less-or-equally specific rule. // 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 { while current.get().level > level {
children.push((current.get().source.clone(), current.get().level)); children.push((current.get().source.clone(), current.get().level));
current = current.parent().unwrap().clone(); current = current.parent().unwrap().clone();
@ -369,7 +369,9 @@ impl RuleTree {
// Now the rule is in the relevant place, push the children as // Now the rule is in the relevant place, push the children as
// necessary. // 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. /// Returns new rule nodes without Transitions level rule.
@ -392,7 +394,7 @@ impl RuleTree {
let iter = path.self_and_ancestors().take_while( let iter = path.self_and_ancestors().take_while(
|node| node.cascade_level() >= CascadeLevel::SMILOverride); |node| node.cascade_level() >= CascadeLevel::SMILOverride);
let mut last = path; let mut last = path;
let mut children = vec![]; let mut children = SmallVec::<[_; 10]>::new();
for node in iter { for node in iter {
if !node.cascade_level().is_animation() { if !node.cascade_level().is_animation() {
children.push((node.get().source.clone(), node.cascade_level())); children.push((node.get().source.clone(), node.cascade_level()));
@ -400,7 +402,8 @@ impl RuleTree {
last = node; 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
} }
} }