diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-09-24 20:44:59 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-09-24 20:44:59 +0000 |
commit | 3e10b45690eb88bd721ef3895015b2032cb39722 (patch) | |
tree | 23e503366ebab89cea696adc5e496363d0398ca5 /usr.bin | |
parent | b0606d6f3764ec0b34adca82a60fb88c0bd70e20 (diff) |
Some minor performance improvements - most notably, don't search the
input state table if the next character matches the same state as before.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/grid.c | 24 | ||||
-rw-r--r-- | usr.bin/tmux/input.c | 29 | ||||
-rw-r--r-- | usr.bin/tmux/log.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 8 |
4 files changed, 38 insertions, 28 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 18e2c73a7d6..3c6fa2e6ec6 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.99 2019/08/01 07:08:13 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.100 2019/09/24 20:44:58 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -186,17 +186,19 @@ grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg) struct grid_cell *gc; memcpy(gce, &grid_cleared_entry, sizeof *gce); - if (bg & COLOUR_FLAG_RGB) { - grid_get_extended_cell(gl, gce, gce->flags); - gl->flags |= GRID_LINE_EXTENDED; + if (bg != 8) { + if (bg & COLOUR_FLAG_RGB) { + grid_get_extended_cell(gl, gce, gce->flags); + gl->flags |= GRID_LINE_EXTENDED; - gc = &gl->extddata[gce->offset]; - memcpy(gc, &grid_cleared_cell, sizeof *gc); - gc->bg = bg; - } else { - if (bg & COLOUR_FLAG_256) - gce->flags |= GRID_FLAG_BG256; - gce->data.bg = bg; + gc = &gl->extddata[gce->offset]; + memcpy(gc, &grid_cleared_cell, sizeof *gc); + gc->bg = bg; + } else { + if (bg & COLOUR_FLAG_256) + gce->flags |= GRID_FLAG_BG256; + gce->data.bg = bg; + } } } diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index b1b306f8cc1..49c469ef1b0 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.159 2019/08/05 06:42:02 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.160 2019/09/24 20:44:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -888,7 +888,8 @@ input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len) { struct input_ctx *ictx = wp->ictx; 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; if (len == 0) @@ -916,16 +917,22 @@ input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len) ictx->ch = buf[off++]; /* Find the transition. */ - itr = ictx->state->transitions; - while (itr->first != -1 && itr->last != -1) { - if (ictx->ch >= itr->first && ictx->ch <= itr->last) - break; - itr++; - } - if (itr->first == -1 || itr->last == -1) { - /* No transition? Eh? */ - fatalx("no transition from state"); + if (ictx->state != state || + itr == NULL || + ictx->ch < itr->first || + ictx->ch > itr->last) { + itr = ictx->state->transitions; + while (itr->first != -1 && itr->last != -1) { + if (ictx->ch >= itr->first && ictx->ch <= itr->last) + break; + itr++; + } + if (itr->first == -1 || itr->last == -1) { + /* No transition? Eh? */ + fatalx("no transition from state"); + } } + state = ictx->state; /* * Any state except print stops the current collection. This is diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c index 326def980f6..0bbcb1f7ff5 100644 --- a/usr.bin/tmux/log.c +++ b/usr.bin/tmux/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.25 2017/06/04 08:25:57 nicm Exp $ */ +/* $OpenBSD: log.c,v 1.26 2019/09/24 20:44:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -131,6 +131,9 @@ log_debug(const char *msg, ...) { va_list ap; + if (log_file == NULL) + return; + va_start(ap, msg); log_vwrite(msg, ap); va_end(ap); diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 76bd56cdc5c..561a1ece5d4 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.158 2019/09/24 15:52:14 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.159 2019/09/24 20:44:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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, &gc, ci->data, ci->used); + grid_view_set_cells(s->grid, s->cx, s->cy, &ci->gc, ci->data, ci->used); screen_write_set_cursor(ctx, s->cx + ci->used, -1); 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 * same - input_parse will end the collection when anything that isn't - * a plain character is encountered. Also nothing should make it here - * that isn't a single ASCII character. + * a plain character is encountered. */ collect = 1; |