mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Some minor performance improvements - most notably, don't search the
input state table if the next character matches the same state as before.
This commit is contained in:
		
							
								
								
									
										2
									
								
								grid.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								grid.c
									
									
									
									
									
								
							@@ -186,6 +186,7 @@ grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)
 | 
				
			|||||||
	struct grid_cell	*gc;
 | 
						struct grid_cell	*gc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy(gce, &grid_cleared_entry, sizeof *gce);
 | 
						memcpy(gce, &grid_cleared_entry, sizeof *gce);
 | 
				
			||||||
 | 
						if (bg != 8) {
 | 
				
			||||||
		if (bg & COLOUR_FLAG_RGB) {
 | 
							if (bg & COLOUR_FLAG_RGB) {
 | 
				
			||||||
			grid_get_extended_cell(gl, gce, gce->flags);
 | 
								grid_get_extended_cell(gl, gce, gce->flags);
 | 
				
			||||||
			gl->flags |= GRID_LINE_EXTENDED;
 | 
								gl->flags |= GRID_LINE_EXTENDED;
 | 
				
			||||||
@@ -198,6 +199,7 @@ grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)
 | 
				
			|||||||
				gce->flags |= GRID_FLAG_BG256;
 | 
									gce->flags |= GRID_FLAG_BG256;
 | 
				
			||||||
			gce->data.bg = bg;
 | 
								gce->data.bg = bg;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Check grid y position. */
 | 
					/* Check grid y position. */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								input.c
									
									
									
									
									
								
							@@ -888,7 +888,8 @@ input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct input_ctx		*ictx = wp->ictx;
 | 
						struct input_ctx		*ictx = wp->ictx;
 | 
				
			||||||
	struct screen_write_ctx		*sctx = &ictx->ctx;
 | 
						struct screen_write_ctx		*sctx = &ictx->ctx;
 | 
				
			||||||
	const struct input_transition	*itr;
 | 
						const struct input_state	*state = NULL;
 | 
				
			||||||
 | 
						const struct input_transition	*itr = NULL;
 | 
				
			||||||
	size_t				 off = 0;
 | 
						size_t				 off = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len == 0)
 | 
						if (len == 0)
 | 
				
			||||||
@@ -916,6 +917,10 @@ input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len)
 | 
				
			|||||||
		ictx->ch = buf[off++];
 | 
							ictx->ch = buf[off++];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Find the transition. */
 | 
							/* Find the transition. */
 | 
				
			||||||
 | 
							if (ictx->state != state ||
 | 
				
			||||||
 | 
							    itr == NULL ||
 | 
				
			||||||
 | 
							    ictx->ch < itr->first ||
 | 
				
			||||||
 | 
							    ictx->ch > itr->last) {
 | 
				
			||||||
			itr = ictx->state->transitions;
 | 
								itr = ictx->state->transitions;
 | 
				
			||||||
			while (itr->first != -1 && itr->last != -1) {
 | 
								while (itr->first != -1 && itr->last != -1) {
 | 
				
			||||||
				if (ictx->ch >= itr->first && ictx->ch <= itr->last)
 | 
									if (ictx->ch >= itr->first && ictx->ch <= itr->last)
 | 
				
			||||||
@@ -926,6 +931,8 @@ input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len)
 | 
				
			|||||||
				/* No transition? Eh? */
 | 
									/* No transition? Eh? */
 | 
				
			||||||
				fatalx("no transition from state");
 | 
									fatalx("no transition from state");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							state = ictx->state;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * Any state except print stops the current collection. This is
 | 
							 * Any state except print stops the current collection. This is
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								log.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								log.c
									
									
									
									
									
								
							@@ -131,6 +131,9 @@ log_debug(const char *msg, ...)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	va_list	ap;
 | 
						va_list	ap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (log_file == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_start(ap, msg);
 | 
						va_start(ap, msg);
 | 
				
			||||||
	log_vwrite(msg, ap);
 | 
						log_vwrite(msg, ap);
 | 
				
			||||||
	va_end(ap);
 | 
						va_end(ap);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1326,8 +1326,7 @@ screen_write_collect_end(struct screen_write_ctx *ctx)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy(&gc, &ci->gc, sizeof gc);
 | 
						grid_view_set_cells(s->grid, s->cx, s->cy, &ci->gc, ci->data, ci->used);
 | 
				
			||||||
	grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used);
 | 
					 | 
				
			||||||
	screen_write_set_cursor(ctx, s->cx + ci->used, -1);
 | 
						screen_write_set_cursor(ctx, s->cx + ci->used, -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (xx = s->cx; xx < screen_size_x(s); xx++) {
 | 
						for (xx = s->cx; xx < screen_size_x(s); xx++) {
 | 
				
			||||||
@@ -1351,8 +1350,7 @@ screen_write_collect_add(struct screen_write_ctx *ctx,
 | 
				
			|||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Don't need to check that the attributes and whatnot are still the
 | 
						 * Don't need to check that the attributes and whatnot are still the
 | 
				
			||||||
	 * same - input_parse will end the collection when anything that isn't
 | 
						 * same - input_parse will end the collection when anything that isn't
 | 
				
			||||||
	 * a plain character is encountered. Also nothing should make it here
 | 
						 * a plain character is encountered.
 | 
				
			||||||
	 * that isn't a single ASCII character.
 | 
					 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	collect = 1;
 | 
						collect = 1;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user