mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rewrite ParallelPostorderDomTraversal::run_parallel to avoid some unnecessary conversions between LayoutNode and UnsafeLayoutNode.
This commit is contained in:
parent
3597c463b5
commit
e6e514c89a
1 changed files with 9 additions and 10 deletions
|
@ -165,14 +165,13 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
|
|||
/// The only communication between siblings is that they both
|
||||
/// fetch-and-subtract the parent's children count.
|
||||
fn run_parallel(&self,
|
||||
mut unsafe_node: UnsafeLayoutNode,
|
||||
unsafe_node: UnsafeLayoutNode,
|
||||
proxy: &mut WorkerProxy<SharedLayoutContext, UnsafeLayoutNodeList>) {
|
||||
// Get a real layout node.
|
||||
let mut node: LayoutNode = unsafe {
|
||||
layout_node_from_unsafe_layout_node(&unsafe_node)
|
||||
};
|
||||
loop {
|
||||
// Get a real layout node.
|
||||
let node: LayoutNode = unsafe {
|
||||
layout_node_from_unsafe_layout_node(&unsafe_node)
|
||||
};
|
||||
|
||||
// Perform the appropriate operation.
|
||||
self.process(node);
|
||||
|
||||
|
@ -186,18 +185,18 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
|
|||
&*parent.borrow_layout_data_unchecked()
|
||||
};
|
||||
let parent_layout_data = parent_layout_data.as_ref().expect("no layout data");
|
||||
unsafe_node = layout_node_to_unsafe_layout_node(&parent);
|
||||
|
||||
if parent_layout_data
|
||||
.data
|
||||
.parallel
|
||||
.children_count
|
||||
.fetch_sub(1, Ordering::Relaxed) == 1 {
|
||||
// We were the last child of our parent. Construct flows for our parent.
|
||||
} else {
|
||||
.fetch_sub(1, Ordering::Relaxed) != 1 {
|
||||
// Get out of here and find another node to work on.
|
||||
break
|
||||
}
|
||||
|
||||
// We were the last child of our parent. Construct flows for our parent.
|
||||
node = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue