mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-03 16:46:18 +00:00 
			
		
		
		
	Do not go through the whole attributes setting process if the new cell
is the same as the previous one.
This commit is contained in:
		
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1054,6 +1054,9 @@ struct tty {
 | 
			
		||||
 | 
			
		||||
	struct grid_cell cell;
 | 
			
		||||
 | 
			
		||||
	int              last_wp;
 | 
			
		||||
	struct grid_cell last_cell;
 | 
			
		||||
 | 
			
		||||
#define TTY_NOCURSOR 0x1
 | 
			
		||||
#define TTY_FREEZE 0x2
 | 
			
		||||
#define TTY_TIMER 0x4
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								tty.c
									
									
									
									
									
								
							@@ -246,6 +246,9 @@ tty_start_tty(struct tty *tty)
 | 
			
		||||
	tty_putcode(tty, TTYC_SGR0);
 | 
			
		||||
	memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell);
 | 
			
		||||
 | 
			
		||||
	memcpy(&tty->last_cell, &grid_default_cell, sizeof tty->last_cell);
 | 
			
		||||
	tty->last_wp = -1;
 | 
			
		||||
 | 
			
		||||
	tty_putcode(tty, TTYC_RMKX);
 | 
			
		||||
	if (tty_use_acs(tty))
 | 
			
		||||
		tty_putcode(tty, TTYC_ENACS);
 | 
			
		||||
@@ -1250,13 +1253,15 @@ tty_reset(struct tty *tty)
 | 
			
		||||
{
 | 
			
		||||
	struct grid_cell	*gc = &tty->cell;
 | 
			
		||||
 | 
			
		||||
	if (grid_cells_equal(gc, &grid_default_cell))
 | 
			
		||||
		return;
 | 
			
		||||
	if (!grid_cells_equal(gc, &grid_default_cell)) {
 | 
			
		||||
		if ((gc->attr & GRID_ATTR_CHARSET) && tty_use_acs(tty))
 | 
			
		||||
			tty_putcode(tty, TTYC_RMACS);
 | 
			
		||||
		tty_putcode(tty, TTYC_SGR0);
 | 
			
		||||
		memcpy(gc, &grid_default_cell, sizeof *gc);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((gc->attr & GRID_ATTR_CHARSET) && tty_use_acs(tty))
 | 
			
		||||
		tty_putcode(tty, TTYC_RMACS);
 | 
			
		||||
	tty_putcode(tty, TTYC_SGR0);
 | 
			
		||||
	memcpy(gc, &grid_default_cell, sizeof *gc);
 | 
			
		||||
	memcpy(&tty->last_cell, &grid_default_cell, sizeof tty->last_cell);
 | 
			
		||||
	tty->last_wp = -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Turn off margin. */
 | 
			
		||||
@@ -1478,6 +1483,18 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
 | 
			
		||||
	struct grid_cell	*tc = &tty->cell, gc2;
 | 
			
		||||
	u_char			 changed;
 | 
			
		||||
 | 
			
		||||
	/* Ignore cell if it is the same as the last one. */
 | 
			
		||||
	if (wp != NULL &&
 | 
			
		||||
	    (int)wp->id == tty->last_wp &&
 | 
			
		||||
	    ~(wp->window->flags & WINDOW_STYLECHANGED) &&
 | 
			
		||||
	    gc->attr == tty->last_cell.attr &&
 | 
			
		||||
	    gc->fg == tty->last_cell.fg &&
 | 
			
		||||
	    gc->bg == tty->last_cell.bg)
 | 
			
		||||
		return;
 | 
			
		||||
	tty->last_wp = (wp != NULL ? (int)wp->id : -1);
 | 
			
		||||
	memcpy(&tty->last_cell, gc, sizeof tty->last_cell);
 | 
			
		||||
 | 
			
		||||
	/* Copy cell and update default colours. */
 | 
			
		||||
	memcpy(&gc2, gc, sizeof gc2);
 | 
			
		||||
	if (wp != NULL)
 | 
			
		||||
		tty_default_colours(&gc2, wp);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user