Don't create unneeded temporaries in style traversals.

This commit is contained in:
Emilio Cobos Álvarez 2016-08-10 11:26:49 -07:00
parent d1090065f7
commit 9b8eac000f
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 7 additions and 19 deletions

View file

@ -67,15 +67,10 @@ fn top_down_dom<N, C>(unsafe_nodes: UnsafeNodeList,
continue; continue;
} }
// Perform the appropriate traversal.
let should_stop = match context.process_preorder(node) {
RestyleResult::Stop => true,
RestyleResult::Continue => false,
};
// Possibly enqueue the children. // Possibly enqueue the children.
let mut children_to_process = 0isize; let mut children_to_process = 0isize;
if !should_stop { // Perform the appropriate traversal.
if let RestyleResult::Continue = context.process_preorder(node) {
for kid in node.children() { for kid in node.children() {
// Trigger the hook pre-adding the kid to the list. This can // Trigger the hook pre-adding the kid to the list. This can
// (and in fact uses to) change the result of the should_process // (and in fact uses to) change the result of the should_process
@ -95,12 +90,10 @@ fn top_down_dom<N, C>(unsafe_nodes: UnsafeNodeList,
// Reset the count of children if we need to do a bottom-up traversal // Reset the count of children if we need to do a bottom-up traversal
// after the top up. // after the top up.
if context.needs_postorder_traversal() { if context.needs_postorder_traversal() {
{ node.mutate_data().unwrap()
let data = node.mutate_data().unwrap(); .parallel.children_to_process
data.parallel.children_to_process .store(children_to_process,
.store(children_to_process, Ordering::Relaxed);
Ordering::Relaxed);
}
// If there were no more children, start walking back up. // If there were no more children, start walking back up.
if children_to_process == 0 { if children_to_process == 0 {

View file

@ -17,12 +17,7 @@ pub fn traverse_dom<N, C>(root: N,
C: DomTraversalContext<N> C: DomTraversalContext<N>
{ {
debug_assert!(context.should_process(node)); debug_assert!(context.should_process(node));
let should_stop = match context.process_preorder(node) { if let RestyleResult::Continue = context.process_preorder(node) {
RestyleResult::Stop => true,
RestyleResult::Continue => false,
};
if !should_stop {
for kid in node.children() { for kid in node.children() {
context.pre_process_child_hook(node, kid); context.pre_process_child_hook(node, kid);
if context.should_process(kid) { if context.should_process(kid) {