diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2017-06-08 16:34:09 -0700 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2017-06-14 22:50:39 -0700 |
commit | c6d0ef5e9fde79eae93791e34379cde9b8f46664 (patch) | |
tree | 23a061a86b2242e518727a4e05c207ddfa5793a5 | |
parent | f04c25c33c7ee92fbeeb3699cb0505dfc3352d07 (diff) | |
download | servo-c6d0ef5e9fde79eae93791e34379cde9b8f46664.tar.gz servo-c6d0ef5e9fde79eae93791e34379cde9b8f46664.zip |
Eliminate an unnecessary heap allocation.
MozReview-Commit-ID: 4cleAH0JsKK
-rw-r--r-- | components/style/parallel.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/components/style/parallel.rs b/components/style/parallel.rs index 2de33023f5e..c2105f097e0 100644 --- a/components/style/parallel.rs +++ b/components/style/parallel.rs @@ -41,8 +41,8 @@ pub const WORK_UNIT_MAX: usize = 16; /// A list of node pointers. /// -/// Note that the inline storage doesn't need to be sized to WORK_UNIT_MAX, but -/// it generally seems sensible to do so. +/// We make the inline storage size WORK_UNIT_MAX so that we can collect chunks +/// into this structure without heap-allocating. type NodeList<N> = SmallVec<[SendNode<N>; WORK_UNIT_MAX]>; /// Entry point for the parallel traversal. @@ -263,11 +263,12 @@ fn traverse_nodes<'a, 'scope, E, D>(nodes: NodeList<E::ConcreteNode>, } } else { for chunk in nodes.chunks(WORK_UNIT_MAX) { - let boxed = chunk.iter().cloned().collect::<Vec<_>>().into_boxed_slice(); + let nodes = chunk.iter().cloned().collect::<NodeList<E::ConcreteNode>>(); + debug_assert!(!nodes.spilled()); let traversal_data_copy = traversal_data.clone(); scope.spawn(move |scope| { - let b = boxed; - top_down_dom(&*b, root, traversal_data_copy, scope, pool, traversal, tls) + let n = nodes; + top_down_dom(&*n, root, traversal_data_copy, scope, pool, traversal, tls) }); } } |