From ec42b42ce601808070462111c0c28edb0e89babb Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 5 Nov 2020 04:45:14 +0000 Subject: Use dynamic storage for zerowidth characters The zerowidth characters were conventionally stored in a [char; 5]. This creates problems both by limiting the maximum number of zerowidth characters and by increasing the cell size beyond what is necessary even when no zerowidth characters are used. Instead of storing zerowidth characters as a slice, a new CellExtra struct is introduced which can store arbitrary optional cell data that is rarely required. Since this is stored behind an optional pointer (Option>), the initialization and dropping in the case of no extra data are extremely cheap and the size penalty to cells without this extra data is limited to 8 instead of 20 bytes. The most noticible difference with this PR should be a reduction in memory size of up to at least 30% (1.06G -> 733M, 100k scrollback, 72 lines, 280 columns). Since the zerowidth characters are now stored dynamically, the limit of 5 per cell is also no longer present. --- alacritty/src/event.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'alacritty/src/event.rs') diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 6c5318f6..0f9c24a5 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -34,7 +34,6 @@ use alacritty_terminal::grid::{Dimensions, Scroll}; use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point, Side}; use alacritty_terminal::selection::{Selection, SelectionType}; use alacritty_terminal::sync::FairMutex; -use alacritty_terminal::term::cell::Cell; use alacritty_terminal::term::{ClipboardType, SizeInfo, Term, TermMode}; #[cfg(not(windows))] use alacritty_terminal::tty; @@ -1174,7 +1173,7 @@ impl Processor { fn write_ref_test_results(&self, terminal: &Term) { // Dump grid state. let mut grid = terminal.grid().clone(); - grid.initialize_all(Cell::default()); + grid.initialize_all(); grid.truncate(); let serialized_grid = json::to_string(&grid).expect("serialize grid"); -- cgit