summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/grid/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2019-12-10 00:35:13 +0100
committerGitHub <noreply@github.com>2019-12-10 00:35:13 +0100
commit36185c47533d6189c9116df7a41a13766ca2b40c (patch)
tree80089a2da7de8701f59b1e692041f0de06c01aee /alacritty_terminal/src/grid/mod.rs
parent79b19176eeb57fbd6b137160afd6bc9f5518ad33 (diff)
downloadalacritty-36185c47533d6189c9116df7a41a13766ca2b40c.tar.gz
alacritty-36185c47533d6189c9116df7a41a13766ca2b40c.zip
Fix colored row reset performance
This fixes a bug where a row would always get reset completely if its background does not equal the default terminal background. This leads to big performance bottlenecks when running commands like `echo "\e[41m" && yes`. Instead of resetting the entire row whenever the template cell is not empty, the template cell is now compared to the last cell in the row. The last cell will always be equal to the previous template cell when `row.occ < row.inner.len()` and if `occ` is equal to the row's length, the entire row is always reset anyways. Fixes #2989.
Diffstat (limited to 'alacritty_terminal/src/grid/mod.rs')
-rw-r--r--alacritty_terminal/src/grid/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs
index 09333b36..ad9d9b7b 100644
--- a/alacritty_terminal/src/grid/mod.rs
+++ b/alacritty_terminal/src/grid/mod.rs
@@ -70,6 +70,12 @@ pub trait GridCell {
fn is_empty(&self) -> bool;
fn is_wrap(&self) -> bool;
fn set_wrap(&mut self, wrap: bool);
+
+ /// Fast equality approximation.
+ ///
+ /// This is a faster alternative to [`PartialEq`],
+ /// but might report inequal cells as equal.
+ fn fast_eq(&self, other: Self) -> bool;
}
/// Represents the terminal display contents
@@ -140,7 +146,7 @@ pub enum Scroll {
Bottom,
}
-impl<T: GridCell + Copy + Clone> Grid<T> {
+impl<T: GridCell + PartialEq + Copy> Grid<T> {
pub fn new(lines: index::Line, cols: index::Column, scrollback: usize, template: T) -> Grid<T> {
let raw = Storage::with_capacity(lines, Row::new(cols, &template));
Grid {