Do not use ParallelIterator if not using rayon

This commit is contained in:
Naveen Gattu 2021-11-30 12:51:56 -08:00 committed by GitHub
parent 6fced22e47
commit 9af545e4e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -134,20 +134,27 @@ impl BlockContainer {
),
}
}
pub(super) fn inline_content_sizes(
&self,
layout_context: &LayoutContext,
writing_mode: WritingMode,
) -> ContentSizes {
match &self {
Self::BlockLevelBoxes(boxes) => boxes
Self::BlockLevelBoxes(boxes) if layout_context.use_rayon => boxes
.par_iter()
.map(|box_| {
box_.borrow_mut()
.inline_content_sizes(layout_context, writing_mode)
})
.reduce(ContentSizes::zero, ContentSizes::max),
Self::BlockLevelBoxes(boxes) => boxes
.iter()
.map(|box_| {
box_.borrow_mut()
.inline_content_sizes(layout_context, writing_mode)
})
.reduce(ContentSizes::max).unwrap_or_else(ContentSizes::zero),
Self::InlineFormattingContext(context) => {
context.inline_content_sizes(layout_context, writing_mode)
},