Skip to content
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

Table widget refactors #1776

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Table widget refactors #1776

merged 2 commits into from
Nov 26, 2024

Conversation

grahamsmith
Copy link
Contributor

Started looking to see if the Multipage and Table performance can be enhanced with larger datasets.

Thought a small PR to start with would be easier.

Refactored to eliminate nullable doubles and reduce force unboxing.

@grahamsmith
Copy link
Contributor Author

@DavBfr I think my formatter is different to yours, are you at 80 chars?

bottom: side,
left: side,
horizontalInside: side,
verticalInside: side,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added trailing comma to force formatting

@@ -149,15 +149,14 @@ class TableContext extends WidgetContext {
class ColumnLayout {
ColumnLayout(this.width, this.flex);

final double? width;
final double? flex;
final double width;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the null here makes the amount the work later on easier. I couldn't find a case where they would be.

final columnWidth = columnWidths != null && columnWidths![n] != null
? columnWidths![n]!
: defaultColumnWidth;
for (final entry in row.children.asMap().entries) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this is a bit more legible and no longer has to worry about null as much

@DavBfr
Copy link
Owner

DavBfr commented Nov 12, 2024

@DavBfr I think my formatter is different to yours, are you at 80 chars?

Yes I am using the default remanded dart formatting.

@grahamsmith
Copy link
Contributor Author

I'll update with 80 chars.

It'll be the same code.

@grahamsmith
Copy link
Contributor Author

@DavBfr - sorted - line lengths are 80 so the diff is simpler now

Unsure about the CI failures from the last run

@grahamsmith
Copy link
Contributor Author

@DavBfr - in my next PR I have extracted the width calculation to its own function, and added it what I hope would be a decent performance enhancement to reuse the calculations if all the column widths are fixed. It would mean we wouldn't have to calculate for every multipage page the width again.

@grahamsmith
Copy link
Contributor Author

@DavBfr - sorry not relevant to this PR but do not know where else to post as too excited

before my changes for a demo pdf with 10,000 items into a table it took 0:00:57.012834
my new fork with changes 0:00:11.770033

Nothing too major either!

Much excite

@DavBfr
Copy link
Owner

DavBfr commented Nov 14, 2024

Congrats!

@grahamsmith
Copy link
Contributor Author

I noticed the checks have passed, do I need to do anything else @DavBfr ?

@DavBfr
Copy link
Owner

DavBfr commented Nov 14, 2024

Just need some time to review.

@DavBfr DavBfr mentioned this pull request Nov 14, 2024
3 tasks
@Gustl22
Copy link

Gustl22 commented Nov 14, 2024

@grahamsmith this will potentially conflicting with #1736, where some changes to the algorithm were made. Hope we find a good solution to make it perform good also with cell spans enabled (haven't tested the performance yet, though).

@grahamsmith
Copy link
Contributor Author

I imagine it will be terrible, although a potential useful feature.

I have more changes in the background that greatly enhance the performance of the layout as its quite slow as other's have mentioned.

Wonder if the spanning could be in a specific set of widgets. In a perfect world would really love to know how many users need cell spanning (clearly you did).

@grahamsmith
Copy link
Contributor Author

@Gustl22 - do you know when your changes will land? I am not particularly precious about this PR. One of the biggest gains is in MultiPage so I can do a seperate PR for that and hopefully it will not clash.

@Gustl22
Copy link

Gustl22 commented Nov 14, 2024

do you know when your changes will land?

No I don't, open source takes time, just wanted to make aware of this conflict. I am also lacking the time to review my stuff in my repos.

Wonder if the spanning could be in a specific set of widgets. In a perfect world would really love to know how many users need cell spanning (clearly you did).

At least 14 people created or upvoted an issue regarding that. And I think the most people are working around this by creating nested tables or column and row layouts, but that's not the clean way. I don't mind which one is merged first, I also have to create performance tests.

There surely can made also optimizations, especially if no cell span is present.

@DavBfr DavBfr merged commit c49c37d into DavBfr:master Nov 26, 2024
6 checks passed
@DavBfr
Copy link
Owner

DavBfr commented Nov 26, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants