Bug 1746920 - Use ThreadPool::scope_fifo in style. r=TYLin

It does the same, but it saves an indentation level:

  https://searchfox.org/mozilla-central/rev/a11b63915bd7810a03635d733123448ab5bfcad3/third_party/rust/rayon-core/src/thread_pool/mod.rs#217

Differential Revision: https://phabricator.services.mozilla.com/D134321
This commit is contained in:
Emilio Cobos Álvarez 2021-12-20 23:55:36 +00:00
parent b882b991aa
commit 2ac050afaa

View File

@ -133,28 +133,26 @@ where
let tls = ScopedTLS::<ThreadLocalStyleContext<E>>::new(pool);
let root_opaque = root.as_node().opaque();
let drain = discovered.drain(..);
pool.install(|| {
pool.scope_fifo(|scope| {
// Enable a breadth-first rayon traversal. This causes the work
// queue to be always FIFO, rather than FIFO for stealers and
// FILO for the owner (which is what rayon does by default). This
// ensures that we process all the elements at a given depth before
// proceeding to the next depth, which is important for style sharing.
rayon::scope_fifo(|scope| {
gecko_profiler_label!(Layout, StyleComputation);
parallel::traverse_nodes(
drain,
DispatchMode::TailCall,
/* recursion_ok = */ true,
root_opaque,
PerLevelTraversalData {
current_dom_depth: depth,
},
scope,
pool,
traversal,
&tls,
);
});
gecko_profiler_label!(Layout, StyleComputation);
parallel::traverse_nodes(
drain,
DispatchMode::TailCall,
/* recursion_ok = */ true,
root_opaque,
PerLevelTraversalData {
current_dom_depth: depth,
},
scope,
pool,
traversal,
&tls,
);
});
tls_slots = Some(tls.into_slots());