diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-05-22 22:48:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-22 22:48:43 +0000 |
commit | 3c61e075fef7b02ae0d043e4a4e664b8bc7221e9 (patch) | |
tree | f1aa2b0bc18ddea72ef8b989d41fa9d915f6d300 /alacritty_terminal/src/term/mod.rs | |
parent | c17d8db16934fa2dbd667acea697cd0682826c80 (diff) | |
download | alacritty-3c61e075fef7b02ae0d043e4a4e664b8bc7221e9.tar.gz alacritty-3c61e075fef7b02ae0d043e4a4e664b8bc7221e9.zip |
Improve rendering performance
This PR combines a couple of optimizations to drastically reduce the
time it takes to gather everything necessary for rendering Alacritty's
terminal grid.
To help with the iteration over the grid, the `DisplayIter` which made
heavy use of dynamic dispatch has been replaced with a simple addition
to the `GridIterator` which also had the benefit of making the code a
little easier to understand.
The hints/search check for each cell was always performing an array
lookup before figuring out that the cell is not part of a hint or
search. Since the general case is that the cell is neither part of hints
or search, they've been wrapped in an `Option` to make verifying their
activity a simple `is_some()` check.
For some reason the compiler was also struggling with the `cursor`
method of the `RenderableContent`. Since the iterator is explicitly
drained, the performance took a hit of multiple milliseconds for a
single branch. Our implementation does never reach the case where
draining the iterator would be necessary, so this sanity check has just
been replaced with a `debug_assert`.
Overall this has managed to reduce the time it takes to collect all
renderable content from ~7-8ms in my large grid test to just ~3-4ms.
Diffstat (limited to 'alacritty_terminal/src/term/mod.rs')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 409d4ebe..2fb4da34 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -15,7 +15,7 @@ use crate::ansi::{ }; use crate::config::Config; use crate::event::{Event, EventListener}; -use crate::grid::{Dimensions, DisplayIter, Grid, Scroll}; +use crate::grid::{Dimensions, Grid, GridIterator, Scroll}; use crate::index::{self, Boundary, Column, Direction, Line, Point, Side}; use crate::selection::{Selection, SelectionRange}; use crate::term::cell::{Cell, Flags, LineLength}; @@ -1828,7 +1828,7 @@ impl RenderableCursor { /// /// This contains all content required to render the current terminal view. pub struct RenderableContent<'a> { - pub display_iter: DisplayIter<'a, Cell>, + pub display_iter: GridIterator<'a, Cell>, pub selection: Option<SelectionRange>, pub cursor: RenderableCursor, pub display_offset: usize, |