-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dynamic row height offset bug #4
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this still suffer from the n*log(n) issue you mention here?
facebookarchive/fixed-data-table#405
Or is it only m*log(n) where m is the number of rows we render?
-- edit --
If we're just operating over the rows on screen I can't imagine m*log(n) would be very slow, but if it is we could optimize the rowPositionGetter method used for this case since I think we should be able to do it in m + log(n) time.
Rambling thoughts on that below.
Would it be possible to just run rowPositionGetter for the first row in the sorted range and then compute the rest by adding the result of getRowHeight to a sum here? That should give the performance increase I'm imagining.
We'd want to push the logic into scroll helper and have it return an array of rowPositions so it could also do the work of _updateRowHeight. Also we should be wary of off by one errors since I'm not 100% sure if row 2's position is row 1's position + row 1's height or row 1's position + row 2's height (probably the first case though).
We'll still see m*log(n) time from updating the PrefixIntervalTree when we first see row heights. It'd be great if we could batch those updates as well since the m rows being rendered probably share many of the same parent nodes in that tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No nLogN performance issue, I misread the code somewhere.
If m is the visible row count, we have m log m from the sort, and m log n from rowPositionGetter. The total complexity remains unchanged, since m > n.
I agree that we could manually iterate on the first position getter, reducing it to m + logN, but I think we should do that in a follow up review. I'm not imagining the priority for that is super high, plus its out of scope for this bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm, it's not worth the added complexity unless we see a perf issue.