From 9b8eac000f86badbd0224d1cb5b183c091fe7c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 10 Aug 2016 11:26:49 -0700 Subject: [PATCH] Don't create unneeded temporaries in style traversals. --- components/style/parallel.rs | 19 ++++++------------- components/style/sequential.rs | 7 +------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/components/style/parallel.rs b/components/style/parallel.rs index 25d61d99d79..532bde8540a 100644 --- a/components/style/parallel.rs +++ b/components/style/parallel.rs @@ -67,15 +67,10 @@ fn top_down_dom(unsafe_nodes: UnsafeNodeList, continue; } - // Perform the appropriate traversal. - let should_stop = match context.process_preorder(node) { - RestyleResult::Stop => true, - RestyleResult::Continue => false, - }; - // Possibly enqueue the children. 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() { // Trigger the hook pre-adding the kid to the list. This can // (and in fact uses to) change the result of the should_process @@ -95,12 +90,10 @@ fn top_down_dom(unsafe_nodes: UnsafeNodeList, // Reset the count of children if we need to do a bottom-up traversal // after the top up. if context.needs_postorder_traversal() { - { - let data = node.mutate_data().unwrap(); - data.parallel.children_to_process - .store(children_to_process, - Ordering::Relaxed); - } + node.mutate_data().unwrap() + .parallel.children_to_process + .store(children_to_process, + Ordering::Relaxed); // If there were no more children, start walking back up. if children_to_process == 0 { diff --git a/components/style/sequential.rs b/components/style/sequential.rs index b19f376302c..334eecc5959 100644 --- a/components/style/sequential.rs +++ b/components/style/sequential.rs @@ -17,12 +17,7 @@ pub fn traverse_dom(root: N, C: DomTraversalContext { debug_assert!(context.should_process(node)); - let should_stop = match context.process_preorder(node) { - RestyleResult::Stop => true, - RestyleResult::Continue => false, - }; - - if !should_stop { + if let RestyleResult::Continue = context.process_preorder(node) { for kid in node.children() { context.pre_process_child_hook(node, kid); if context.should_process(kid) {