mirror of
https://github.com/tmux/tmux.git
synced 2024-10-31 22:58:49 +00:00
A few trivial optimisations: no need to check for zero size if calling
buffer_ensure in buffer.c; expand grid lines by a greater increase than one each time; and don't read UTF-8 data unless it actually needs to be checked when overwriting a cell.
This commit is contained in:
parent
234ad54b2c
commit
1501b3fbbd
5
buffer.c
5
buffer.c
@ -100,9 +100,6 @@ buffer_remove(struct buffer *b, size_t size)
|
||||
void
|
||||
buffer_write(struct buffer *b, const void *data, size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
fatalx("zero size");
|
||||
|
||||
buffer_ensure(b, size);
|
||||
memcpy(BUFFER_IN(b), data, size);
|
||||
buffer_add(b, size);
|
||||
@ -127,7 +124,7 @@ buffer_write8(struct buffer *b, uint8_t n)
|
||||
{
|
||||
buffer_ensure(b, 1);
|
||||
BUFFER_IN(b)[0] = n;
|
||||
buffer_add(b, 1);
|
||||
b->size++;
|
||||
}
|
||||
|
||||
/* Extract an 8-bit value. */
|
||||
|
4
grid.c
4
grid.c
@ -198,6 +198,10 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx)
|
||||
if (sx <= gl->cellsize)
|
||||
return;
|
||||
|
||||
if (gl->cellsize > gd->sx / 2)
|
||||
sx = gd->sx;
|
||||
else
|
||||
sx = 1 + gl->cellsize * 2;
|
||||
gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata);
|
||||
for (xx = gl->cellsize; xx < sx; xx++)
|
||||
grid_put_cell(gd, xx, py, &grid_default_cell);
|
||||
|
@ -858,7 +858,8 @@ screen_write_overwrite(struct screen_write_ctx *ctx)
|
||||
u_int xx;
|
||||
|
||||
gc = grid_view_peek_cell(gd, s->cx, s->cy);
|
||||
gu = grid_view_peek_utf8(gd, s->cx, s->cy);
|
||||
if (gc->flags & GRID_FLAG_UTF8)
|
||||
gu = grid_view_peek_utf8(gd, s->cx, s->cy);
|
||||
|
||||
if (gc->flags & GRID_FLAG_PADDING) {
|
||||
/*
|
||||
@ -885,16 +886,19 @@ screen_write_overwrite(struct screen_write_ctx *ctx)
|
||||
break;
|
||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||
}
|
||||
} else if (gc->flags & GRID_FLAG_UTF8 && gu->width > 1) {
|
||||
/*
|
||||
* An UTF-8 wide cell; overwrite following padding cells only.
|
||||
*/
|
||||
xx = s->cx;
|
||||
while (++xx < screen_size_x(s)) {
|
||||
gc = grid_view_peek_cell(gd, xx, s->cy);
|
||||
if (!(gc->flags & GRID_FLAG_PADDING))
|
||||
break;
|
||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||
} else if (gc->flags & GRID_FLAG_UTF8) {
|
||||
gu = grid_view_peek_utf8(gd, s->cx, s->cy);
|
||||
if (gu->width > 1) {
|
||||
/*
|
||||
* An UTF-8 wide cell; overwrite following padding cells only.
|
||||
*/
|
||||
xx = s->cx;
|
||||
while (++xx < screen_size_x(s)) {
|
||||
gc = grid_view_peek_cell(gd, xx, s->cy);
|
||||
if (!(gc->flags & GRID_FLAG_PADDING))
|
||||
break;
|
||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user