From 9fdf77f91a057216c7755b9db5012fa5fa5426ef Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 12 Oct 2017 20:29:35 -0700 Subject: [PATCH] Remove some unused methods and impls --- src/grid/mod.rs | 16 ++-------------- src/grid/row.rs | 43 +++++++++++++++++-------------------------- src/term/mod.rs | 7 ++----- tests/ref.rs | 3 ++- 4 files changed, 23 insertions(+), 46 deletions(-) diff --git a/src/grid/mod.rs b/src/grid/mod.rs index cd621adb..9c398171 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -122,7 +122,7 @@ impl Grid { } fn grow_cols(&mut self, cols: index::Column, template: &T) { - for row in self.lines_mut() { + for row in self.raw.iter_mut() { row.grow(cols, template); } @@ -131,19 +131,7 @@ impl Grid { } - - impl Grid { - #[inline] - pub fn lines(&self) -> vec_deque::Iter> { - self.raw.iter() - } - - #[inline] - pub fn lines_mut(&mut self) -> vec_deque::IterMut> { - self.raw.iter_mut() - } - #[inline] pub fn num_lines(&self) -> index::Line { self.lines @@ -216,7 +204,7 @@ impl Grid { } fn shrink_cols(&mut self, cols: index::Column) { - for row in self.lines_mut() { + for row in self.raw.iter_mut() { row.shrink(cols); } diff --git a/src/grid/row.rs b/src/grid/row.rs index 8711d04f..4b355a56 100644 --- a/src/grid/row.rs +++ b/src/grid/row.rs @@ -108,33 +108,8 @@ impl IndexMut for Row { } } -macro_rules! row_index_range { - ($range:ty) => { - impl Index<$range> for Row { - type Output = [T]; - - #[inline] - fn index(&self, index: $range) -> &[T] { - &self.0[index] - } - } - - impl IndexMut<$range> for Row { - #[inline] - fn index_mut(&mut self, index: $range) -> &mut [T] { - &mut self.0[index] - } - } - } -} - -row_index_range!(Range); -row_index_range!(RangeTo); -row_index_range!(RangeFrom); -row_index_range!(RangeFull); - // ----------------------------------------------------------------------------- -// Column ranges for Row +// Index ranges of columns // ----------------------------------------------------------------------------- impl Index> for Row { @@ -184,3 +159,19 @@ impl IndexMut> for Row { &mut self.0[(index.start.0)..] } } + +impl Index for Row { + type Output = [T]; + + #[inline] + fn index(&self, _: RangeFull) -> &[T] { + &self.0[..] + } +} + +impl IndexMut for Row { + #[inline] + fn index_mut(&mut self, _: RangeFull) -> &mut [T] { + &mut self.0[..] + } +} diff --git a/src/term/mod.rs b/src/term/mod.rs index 80e370e7..d60a3f52 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -1297,11 +1297,8 @@ impl ansi::Handler for Term { let mut template = self.cursor.template; template.c = 'E'; - for row in &mut self.grid.lines_mut() { - for cell in row { - cell.reset(&template); - } - } + self.grid.region_mut(..) + .each(|c| c.reset(&template)); } #[inline] diff --git a/tests/ref.rs b/tests/ref.rs index 2a093704..6836a9f5 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -6,6 +6,7 @@ use std::io::{self, Read}; use std::path::Path; use alacritty::Grid; +use alacritty::grid::IndexRegion; use alacritty::Term; use alacritty::ansi; use alacritty::index::{Line, Column}; @@ -84,7 +85,7 @@ fn ref_test(dir: &Path) { } if grid != *terminal.grid() { - for (i, row) in terminal.grid().lines().enumerate() { + for (i, row) in terminal.grid().region(..).into_iter().enumerate() { for (j, cell) in row.iter().enumerate() { let original_cell = &grid[Line(i)][Column(j)]; if *original_cell != *cell {