Improve performance of content size calculation in List #4835
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Makes calculating the content size in List O(n) in the number of custom-height items rather than the number of total items. Unsurprisingly, a huge performance improvement for long lists with only a few custom item heights (as is a common use case).
Fixes #3427 (for list)
Checklist:
Benchmark (before):
goos: darwin goarch: arm64 pkg: fyne.io/fyne/v2/widget
BenchmarkContentMinSize-8 198 6114649 ns/op 0 B/op 0 allocs/op PASS ok fyne.io/fyne/v2/widget 2.062s
Benchmark (after):
goos: darwin goarch: arm64 pkg: fyne.io/fyne/v2/widget
BenchmarkContentMinSize-8 19891040 51.04 ns/op 0 B/op 0 allocs/op PASS ok fyne.io/fyne/v2/widget 1.565s