kworkflow / patch-hub

patch-hub is a TUI that streamlines the interaction of Linux developers with patches archived on lore.kernel.org
GNU General Public License v2.0
8 stars 6 forks source link

fix: avoid rendering patch previews every frame #86

Closed davidbtadokoro closed 3 weeks ago

davidbtadokoro commented 3 weeks ago

[Context and Fix]

Patch previews can be rendered by external renderers, like bat, delta, and diff-so-fancy. However, this rendering is done for every frame and includes processing the whole patch being previewed through the renderer, then calling into_text() (from ansi_to_tui crate). Even though this whole process isn't too costly, making it at every frame results in ugly slowdowns for not so big patches (around 2000 lines after rendering).

To fix this, move the whole rendering process to when we first instantiate a PatchsetDetailsAndActions, i.e., when consulting a patchset.

[Collateral Effects]

This basically solves the problem, however, there is still minor lag, due to ratatui Paragraph getting the whole file, and, for big series, there is a bit a loading when opening patchsets. Also, this does a bit of coupling of the model (App) with the view (ratatui).

Closes: #77

davidbtadokoro commented 3 weeks ago

@OJarrisonn, can you give a glance here? A simple test and top-to-bottom look at the changes would be of much help.

Of course, if you want to make a full review of the PR, you are more than welcome. Just click on the commits tab and you can start adding comments (just don't forget to publish your review in the top right button).

davidbtadokoro commented 3 weeks ago

Change merged into the unstable branch :+1: