1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-21 19:58:15 +03:00

make it very slightly cheaper to enumerate the screen lines

This commit is contained in:
Wez Furlong 2018-02-17 15:04:48 -08:00
parent f8b596bd7c
commit de700e0207
3 changed files with 7 additions and 5 deletions

View File

@ -949,10 +949,9 @@ impl<'a> TerminalWindow<'a> {
let (r, g, b, a) = background_color.to_linear_tuple_rgba();
target.clear_color(r, g, b, a);
self.terminal.make_all_lines_dirty();
let cursor = self.terminal.cursor_pos();
{
let dirty_lines = self.terminal.get_dirty_lines();
let dirty_lines = self.terminal.get_dirty_lines(true);
for (line_idx, line, selrange) in dirty_lines {
self.render_line(

View File

@ -640,7 +640,7 @@ impl TerminalState {
/// line_idx is relative to the top of the viewport.
/// The selrange value is the column range representing the selected
/// columns on this line.
pub fn get_dirty_lines(&self) -> Vec<(usize, &Line, Range<usize>)> {
pub fn get_dirty_lines(&self, get_all: bool) -> Vec<(usize, &Line, Range<usize>)> {
let mut res = Vec::new();
let screen = self.screen();
@ -650,7 +650,7 @@ impl TerminalState {
let selection = self.selection_range.map(|r| r.normalize());
for (i, mut line) in screen.lines.iter().skip(len - height).enumerate() {
if line.is_dirty() {
if get_all || line.is_dirty() {
let selrange = match selection {
None => 0..0,
Some(sel) => {

View File

@ -191,7 +191,10 @@ impl TestTerm {
}
fn assert_dirty_lines(&self, expected: &[usize], reason: Option<&str>) {
let dirty_indices: Vec<usize> = self.get_dirty_lines().iter().map(|&(i, ..)| i).collect();
let dirty_indices: Vec<usize> = self.get_dirty_lines(false)
.iter()
.map(|&(i, ..)| i)
.collect();
assert_eq!(
&dirty_indices,
&expected,