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

perf(table): avoid extra allocations when rendering Table #1242

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

airblast-dev
Copy link
Contributor

@airblast-dev airblast-dev commented Jul 26, 2024

When rendering a Table the Text stored inside of a Cell gets cloned before rendering. This removes the clone and uses WidgetRef instead, saving us from allocating a Vec<Line<'_>> inside Text. Also avoids an allocation when rendering the highlight symbol if it contains an owned value.

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.6%. Comparing base (7ddfbc0) to head (abe2db4).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1242   +/-   ##
=====================================
  Coverage   94.6%   94.6%           
=====================================
  Files         65      65           
  Lines      15397   15397           
=====================================
  Hits       14566   14566           
  Misses       831     831           

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

@orhun orhun changed the title perf(table): Avoid extra allocations when rendering Table perf(table): avoid extra allocations when rendering Table Jul 26, 2024
@orhun orhun merged commit be3eb75 into ratatui:main Jul 26, 2024
36 checks passed
@airblast-dev airblast-dev deleted the table_allocs branch July 26, 2024 21:02
joshka pushed a commit to erak/ratatui that referenced this pull request Oct 14, 2024
…1242)

When rendering a `Table` the `Text` stored inside of a `Cell` gets
cloned before rendering. This removes the clone and uses `WidgetRef`
instead, saving us from allocating a `Vec<Line<'_>>` inside `Text`. Also
avoids an allocation when rendering the highlight symbol if it contains
an owned value.
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.

4 participants