Commit 2ebf102c authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Avoid NGPaintFragment::List::size()

The use here is for memory alloc performance, but since it
has inline capacity of 64, it won't help when |size()| is
O(n).

Bug: 945671
Change-Id: I166e6615bcae5a814116ee1b6aaf0349405a67ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1535507
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644431}
parent 4cc35386
......@@ -788,8 +788,10 @@ const NGInlineBreakToken* NGBlockLayoutAlgorithm::TryReuseFragmentsFromCache(
const NGPhysicalFragment& fragment;
NGLogicalOffset offset;
};
// Avoid calling |ReserveInitialCapacity()| because
// |lineboxes->Children().size()| is O(n), not linear, but it's critical to
// have enough capacity.
Vector<FragmentWithLogicalOffset, 64> fragments;
fragments.ReserveInitialCapacity(lineboxes->Children().size());
for (const NGPaintFragment* child : lineboxes->Children()) {
if (child->IsDirty())
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment