summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/selection.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-05-22 22:48:43 +0000
committerGitHub <noreply@github.com>2021-05-22 22:48:43 +0000
commit3c61e075fef7b02ae0d043e4a4e664b8bc7221e9 (patch)
treef1aa2b0bc18ddea72ef8b989d41fa9d915f6d300 /alacritty_terminal/src/selection.rs
parentc17d8db16934fa2dbd667acea697cd0682826c80 (diff)
downloadalacritty-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/selection.rs')
-rw-r--r--alacritty_terminal/src/selection.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/alacritty_terminal/src/selection.rs b/alacritty_terminal/src/selection.rs
index 428b3f0e..47a49910 100644
--- a/alacritty_terminal/src/selection.rs
+++ b/alacritty_terminal/src/selection.rs
@@ -13,7 +13,7 @@ use crate::ansi::CursorShape;
use crate::grid::{Dimensions, GridCell, Indexed};
use crate::index::{Boundary, Column, Line, Point, Side};
use crate::term::cell::{Cell, Flags};
-use crate::term::{RenderableCursor, Term};
+use crate::term::Term;
/// A Point and side within that point.
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -56,10 +56,15 @@ impl SelectionRange {
}
/// Check if the cell at a point is part of the selection.
- pub fn contains_cell(&self, indexed: &Indexed<&Cell>, cursor: RenderableCursor) -> bool {
+ pub fn contains_cell(
+ &self,
+ indexed: &Indexed<&Cell>,
+ point: Point,
+ shape: CursorShape,
+ ) -> bool {
// Do not invert block cursor at selection boundaries.
- if cursor.shape == CursorShape::Block
- && cursor.point == indexed.point
+ if shape == CursorShape::Block
+ && point == indexed.point
&& (self.start == indexed.point
|| self.end == indexed.point
|| (self.is_block