Open chris-olszewski opened 1 month ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
examples-basic-web | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-designsystem-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-gatsby-web | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-kitchensink-blog | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-native-web | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-nonmonorepo | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-svelte-web | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-tailwind-web | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
examples-vite-web | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 3, 2024 7:12pm |
Description
The crate
tui_term
renders thevt100::Screen
by fetching each cell and then filling theratatui::buffer:Cell
with the vt100 cell's contents.This leads to the following functions being called once for each cell on the users terminal:
Cell::contents
which unnecessarily allocates on every call even though there's a fixed limit to the size of thestr
that could be returned. This PR changes this method to return a&str
that is constructed from the content bytes. The new helper functionappend_char
is basicallyString::push
Grid::visible_row
which iterates through the scrollback rows and screen rows. This PR changes this to instead index directly into the rowsTesting Instructions
Tested by profiling this basic script that render a tui_term 1000 times.
The two functions that this targets:
fill_buf_cell
codepath BeforeAfter
visible_cell
codepath BeforeAfter