Skip to content

Conversation

@joshka-oai
Copy link
Collaborator

@joshka-oai joshka-oai commented Nov 7, 2025

Removes flush logic that was leftover to test against ratatui's flush
Cleaned up the flush logic so it's a bit more intent revealing.
DrawCommand now owns the Cells that it draws as this works around a borrow checker problem.

Removes flush logic that was leftover to test against ratatui's flush

Plus a small amount of tidying up
Comment on lines 194 to 195
let previous_buffer = &self.buffers[1 - self.current];
let current_buffer = &self.buffers[self.current];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let previous_buffer = &self.buffers[1 - self.current];
let current_buffer = &self.buffers[self.current];
let previous_buffer = self.previous_buffer_mut();
let current_buffer = self.current_buffer_mut();

This requires a clone due to the borrow checker, but It's likely that
this is probably fine due to 10-20k cells being fast enough to not be
too concerned about perf issues on most modern hardware.
@joshka-oai
Copy link
Collaborator Author

@codex review this and check my logic about cloning the buffers being fine from a perf perspective. Use a worst case estimate of a Raspberry Pi 4 and a buffer size of around 50k cells (this represents my guesstimate for tiny text on a 27in 4k monitor). Ack and explain the ack if the estimates are off.

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Avoids cloning the buffers - only clone the changed cells
@joshka-oai
Copy link
Collaborator Author

ChatGPT gave an estimate for a Raspberry Pi 4 (using this as a lowest threshold system). 60fps -> 60% of one core at worst case scenario (big 4k monitor, tiny font = 59k cells). So instead this clones and now the DrawCommand owns the cell instead of a ref in the diff. This means that it cuts that down to a much more reasonable level of only the changes (which are unlikely to be full screen 60fps, more like 100 characters per second for a normal change, and a couple of ms when doing a full screen refresh.


/// Gets the current buffer as a mutable reference.
pub fn current_buffer_mut(&mut self) -> &mut Buffer {
fn current_buffer_mut(&mut self) -> &mut Buffer {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No longer pub because there's nowhere that calls this external to the custom terminal.

@joshka-oai joshka-oai merged commit 9fba811 into main Nov 7, 2025
25 checks passed
@joshka-oai joshka-oai deleted the joshka/remove-deprecated-flush branch November 7, 2025 23:54
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants