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

refactor(widgets): remove unnecessary dynamic dispatch and heap allocation #597

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

rhysd
Copy link
Contributor

@rhysd rhysd commented Oct 26, 2023

This PR refactors implementation of Paragraph::render. It allocates LineComposer trait object on heap memory and calls its methods via dynamic dispatch. However it can be easily changed to static dispatch with allocating the object on stack.

This PR does the change as refactoring. No rendering logic has changed.

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1e2f0be) 90.5% compared to head (3f76164) 90.5%.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #597   +/-   ##
=====================================
  Coverage   90.5%   90.5%           
=====================================
  Files         41      41           
  Lines      11978   11980    +2     
=====================================
+ Hits       10850   10853    +3     
+ Misses      1128    1127    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@joshka joshka left a comment

Choose a reason for hiding this comment

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

I'm a big fan of anything that simplifies complexity like this.
I can merge as-is and apply my nit after if you don't have time to make the suggested change.

src/widgets/paragraph.rs Outdated Show resolved Hide resolved
…ation

Signed-off-by: rhysd <lin90162@yahoo.co.jp>
Copy link
Member

@joshka joshka left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and the requested fixes :)

@joshka joshka merged commit 7ef0afc into ratatui-org:main Nov 22, 2023
33 checks passed
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.

None yet

2 participants