[css-grid] Avoid HashSet when iterating grid items
Both GridTrackSizingAlgorithm::ResolveIntrinsicTrackSizes and IndefiniteSizeStrategy::FindUsedFlexFraction have a vector of track indices and want to iterate the grid items in these tracks. But they only want to do the work once for each item, even if it spans multiple cells in one of these tracks, or it spans multiple of these tracks. What they used to do was to insert the items provided by NextGridItem into a HashSet, and check whether it was a new entry or it was already there. Instead, this patch modifies ListGridIterator::NextGridItem so that it skips items already processed in an earlier cell of that track, and adds a IterateGridItemsInTrackIndices helper function which takes care of creating the iterators, calls NextGridItem, and skips items already processed in an earlier track. The already processed items are detected looking at their indices, so the HashSet is no longer used in release builds. It's only kept in debug builds to ensure that the logic is solid. This should have no effect in practice, other than better performance: the nested-grid-lots-of-tracks perf test improves by ~26%, and the nested-grid, auto-grid-lots-of-data and auto-grid-lots-of-spanning-data improve by 5-7%. On the other hand, fixed-grid-lots-of-data and fixed-grid-lots-of-stretched-data worsen a bit by 2-3%. Change-Id: Ibedbfa48c8825cff129797ba759dc22cf6972017 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508472Reviewed-by:Javier Fernandez <jfernandez@igalia.com> Commit-Queue: Oriol Brufau <obrufau@igalia.com> Cr-Commit-Position: refs/heads/master@{#822623}
Showing
Please register or sign in to comment