From c6d0ef5e9fde79eae93791e34379cde9b8f46664 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 8 Jun 2017 16:34:09 -0700 Subject: [PATCH] Eliminate an unnecessary heap allocation. MozReview-Commit-ID: 4cleAH0JsKK --- components/style/parallel.rs | 11 ++++++----- 1 file 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 = SmallVec<[SendNode; WORK_UNIT_MAX]>; /// Entry point for the parallel traversal. @@ -263,11 +263,12 @@ fn traverse_nodes<'a, 'scope, E, D>(nodes: NodeList, } } else { for chunk in nodes.chunks(WORK_UNIT_MAX) { - let boxed = chunk.iter().cloned().collect::>().into_boxed_slice(); + let nodes = chunk.iter().cloned().collect::>(); + 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) }); } }