mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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
|
/// The only communication between siblings is that they both
|
||||||
/// fetch-and-subtract the parent's children count.
|
/// fetch-and-subtract the parent's children count.
|
||||||
fn run_parallel(&self,
|
fn run_parallel(&self,
|
||||||
mut unsafe_node: UnsafeLayoutNode,
|
unsafe_node: UnsafeLayoutNode,
|
||||||
proxy: &mut WorkerProxy<SharedLayoutContext, UnsafeLayoutNodeList>) {
|
proxy: &mut WorkerProxy<SharedLayoutContext, UnsafeLayoutNodeList>) {
|
||||||
loop {
|
|
||||||
// Get a real layout node.
|
// Get a real layout node.
|
||||||
let node: LayoutNode = unsafe {
|
let mut node: LayoutNode = unsafe {
|
||||||
layout_node_from_unsafe_layout_node(&unsafe_node)
|
layout_node_from_unsafe_layout_node(&unsafe_node)
|
||||||
};
|
};
|
||||||
|
loop {
|
||||||
// Perform the appropriate operation.
|
// Perform the appropriate operation.
|
||||||
self.process(node);
|
self.process(node);
|
||||||
|
|
||||||
|
@ -186,18 +185,18 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
|
||||||
&*parent.borrow_layout_data_unchecked()
|
&*parent.borrow_layout_data_unchecked()
|
||||||
};
|
};
|
||||||
let parent_layout_data = parent_layout_data.as_ref().expect("no layout data");
|
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
|
if parent_layout_data
|
||||||
.data
|
.data
|
||||||
.parallel
|
.parallel
|
||||||
.children_count
|
.children_count
|
||||||
.fetch_sub(1, Ordering::Relaxed) == 1 {
|
.fetch_sub(1, Ordering::Relaxed) != 1 {
|
||||||
// We were the last child of our parent. Construct flows for our parent.
|
|
||||||
} else {
|
|
||||||
// Get out of here and find another node to work on.
|
// Get out of here and find another node to work on.
|
||||||
break
|
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