airbnb / MagazineLayout

A collection view layout capable of laying out views in vertically scrolling grids and lists.
Apache License 2.0
3.28k stars 219 forks source link

Performance improvements during layout calculation #122

Closed elfredpagan closed 6 months ago

elfredpagan commented 6 months ago

Details

Both invalidateSectionMaxYsCacheForSectionIndices and invalidateEntireSectionMaxYsCache do linear passes. These are called on each section header, section footer and background. Leading to a lot of work being done with long lists.

This PR short circuits the work if we try to remove header, footers and backgrounds that don't exist.

A better option would be to run the calls above once per update vs per update item. That would require a bit more rework though.

Related Issue

Motivation and Context

I was working with long lists and was getting a significant amount of hangs. This was before the change:

This was after:

How Has This Been Tested

Tested in the airbnb app.

Types of changes

Checklist

elfredpagan commented 6 months ago

applied the changes.