Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Parallelize BlockContainer::inline_content_sizes
  • Loading branch information
SimonSapin committed Jun 19, 2020
1 parent 5fed956 commit 42e9d24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 7 additions & 11 deletions components/layout_2020/flow/mod.rs
Expand Up @@ -141,17 +141,13 @@ impl BlockContainer {
containing_block_writing_mode: WritingMode,
) -> ContentSizes {
match &self {
Self::BlockLevelBoxes(boxes) => {
let mut content_sizes = ContentSizes::zero();
for box_ in boxes {
content_sizes.max_assign(
&box_
.borrow_mut()
.inline_content_sizes(layout_context, containing_block_writing_mode),
);
}
content_sizes
},
Self::BlockLevelBoxes(boxes) => boxes
.par_iter()
.map(|box_| {
box_.borrow_mut()
.inline_content_sizes(layout_context, containing_block_writing_mode)
})
.reduce(ContentSizes::zero, ContentSizes::max),
Self::InlineFormattingContext(context) => {
context.inline_content_sizes(layout_context, containing_block_writing_mode)
},
Expand Down
8 changes: 5 additions & 3 deletions components/layout_2020/sizing.rs
Expand Up @@ -33,9 +33,11 @@ impl ContentSizes {
}
}

pub fn max_assign(&mut self, other: &Self) {
self.min_content.max_assign(other.min_content);
self.max_content.max_assign(other.max_content);
pub fn max(self, other: Self) -> Self {
Self {
min_content: self.min_content.max(other.min_content),
max_content: self.max_content.max(other.max_content),
}
}

/// Relevant to outer intrinsic inline sizes, for percentages from padding and margin.
Expand Down

0 comments on commit 42e9d24

Please sign in to comment.