Reduce the amount of code in the unsafe block in ParallelPostorderFlowTraversal::run_parallel.

This commit is contained in:
Ms2ger 2015-07-09 13:03:18 +02:00
parent 46b36242a3
commit 5d36fbca29

View file

@ -242,9 +242,10 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
mut unsafe_flow: UnsafeFlow, mut unsafe_flow: UnsafeFlow,
_: &mut WorkerProxy<SharedLayoutContext,UnsafeFlowList>) { _: &mut WorkerProxy<SharedLayoutContext,UnsafeFlowList>) {
loop { loop {
unsafe {
// Get a real flow. // Get a real flow.
let flow: &mut FlowRef = mem::transmute(&mut unsafe_flow); let flow: &mut FlowRef = unsafe {
mem::transmute(&mut unsafe_flow)
};
// Perform the appropriate traversal. // Perform the appropriate traversal.
if self.should_process(&mut **flow) { if self.should_process(&mut **flow) {
@ -268,7 +269,9 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
// No, we're not at the root yet. Then are we the last child // No, we're not at the root yet. Then are we the last child
// of our parent to finish processing? If so, we can continue // of our parent to finish processing? If so, we can continue
// on with our parent; otherwise, we've gotta wait. // on with our parent; otherwise, we've gotta wait.
let parent: &mut FlowRef = mem::transmute(&mut unsafe_parent); let parent: &mut FlowRef = unsafe {
mem::transmute(&mut unsafe_parent)
};
let parent_base = flow::mut_base(&mut **parent); let parent_base = flow::mut_base(&mut **parent);
if parent_base.parallel.children_count.fetch_sub(1, Ordering::Relaxed) == 1 { if parent_base.parallel.children_count.fetch_sub(1, Ordering::Relaxed) == 1 {
// We were the last child of our parent. Reflow our parent. // We were the last child of our parent. Reflow our parent.
@ -280,7 +283,6 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
} }
} }
} }
}
/// A parallel top-down flow traversal. /// A parallel top-down flow traversal.
trait ParallelPreorderFlowTraversal : PreorderFlowTraversal { trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {