summaryrefslogtreecommitdiffstats
path: root/alacritty_terminal
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-01-07 05:19:37 +0000
committerGitHub <noreply@github.com>2021-01-07 05:19:37 +0000
commitfb9b362b6e6722d0bdcb367033e316536963c25a (patch)
tree0a6f81d03783aeea034b10d46fb1b7cb47ab40ae /alacritty_terminal
parent9f560b3e11374118afb9575135dc220d0ace267d (diff)
Fix inefficient search initialization
The creation of the renderable search iterator was doing a lot of work even when absolutely no search is active at the moment. To resolve this problem, an early return now makes sure that a search is active before going through the trouble of creating an iterator for it.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r--alacritty_terminal/src/term/render.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/alacritty_terminal/src/term/render.rs b/alacritty_terminal/src/term/render.rs
index eb4740b3..fbb5a732 100644
--- a/alacritty_terminal/src/term/render.rs
+++ b/alacritty_terminal/src/term/render.rs
@@ -258,6 +258,11 @@ impl RenderableCell {
}
}
+ /// Position of the cell.
+ pub fn point(&self) -> Point {
+ Point::new(self.line, self.column)
+ }
+
/// Check if cell contains any renderable content.
fn is_empty(&self) -> bool {
self.bg_alpha == 0.
@@ -370,6 +375,12 @@ struct RenderableSearch<'a> {
impl<'a> RenderableSearch<'a> {
/// Create a new renderable search iterator.
fn new<T>(term: &'a Term<T>) -> Self {
+ // Avoid constructing search if there is none.
+ if term.regex_search.is_none() {
+ let iter: MatchIter<'a> = Box::new(iter::empty());
+ return Self { iter: iter.peekable() };
+ }
+
let viewport_end = term.grid().display_offset();
let viewport_start = viewport_end + term.screen_lines().0 - 1;