From cf71534768b01e2a94a8f8f13faca2fb1920e93e Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 10 Jul 2019 18:45:12 +0200 Subject: terminal: remove 'blink' attribute from cell struct This makes the other attribute bits fit in a single uint8_t, which makes each cell smaller which improves cache usage. --- terminal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 4ddf017e..66cfebe0 100644 --- a/terminal.h +++ b/terminal.h @@ -56,7 +56,7 @@ struct attributes { uint8_t italic:1; uint8_t underline:1; uint8_t strikethrough:1; - uint8_t blink:1; + //uint8_t blink:1; /* Not supported yet, and removing it means all other attributes fit in a single uint8_t */ uint8_t conceal:1; uint8_t reverse:1; uint8_t have_foreground:1; -- cgit v1.3 From b1f8dd75d684b3dd00f147a63ef687a6b566fc7f Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 10 Jul 2019 18:47:32 +0200 Subject: cell: we only need 4 bytes for the longest utf8 sequence We don't *have* to NULL-terminate the utf8 string. So don't. This makes the cell glyph 4 bytes exactly, which is better for alignment and cache usage. --- render.c | 2 +- terminal.h | 2 +- vt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'terminal.h') diff --git a/render.c b/render.c index 65e2ab96..894bc939 100644 --- a/render.c +++ b/render.c @@ -101,7 +101,7 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell, cairo_status_t status = cairo_scaled_font_text_to_glyphs( attrs_to_font(term, &cell->attrs), x, y + term->fextents.ascent, - cell->c, strlen(cell->c), &gseq.g, &new_glyphs, + cell->c, strnlen(cell->c, 4), &gseq.g, &new_glyphs, NULL, NULL, NULL); if (status != CAIRO_STATUS_SUCCESS) diff --git a/terminal.h b/terminal.h index 66cfebe0..16e53f22 100644 --- a/terminal.h +++ b/terminal.h @@ -68,7 +68,7 @@ struct attributes { struct cell { struct attributes attrs; - char c[5]; + char c[4]; } __attribute__((packed)); struct scroll_region { diff --git a/vt.c b/vt.c index 8314c060..5d4127c5 100644 --- a/vt.c +++ b/vt.c @@ -757,7 +757,7 @@ action_print(struct terminal *term, uint8_t c) if (unlikely(term->charset[term->selected_charset] == CHARSET_GRAPHIC) && c >= 0x41 && c <= 0x7e) { - strcpy(cell->c, vt100_0[c - 0x41]); + strncpy(cell->c, vt100_0[c - 0x41], sizeof(cell->c)); } else { //LOG_DBG("print: ASCII: %c", c); cell->c[0] = c; -- cgit v1.3 From 74ab12010185735c6a1afa1029be3824fa56fc92 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 10 Jul 2019 18:48:46 +0200 Subject: terminal: use floats instead of double for colors We don't need the full resolution a double gives us. Using floats reduces the size of cells greatly, which improves cache usage. --- terminal.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 16e53f22..fdb86a81 100644 --- a/terminal.h +++ b/terminal.h @@ -38,20 +38,13 @@ struct wayland { bool have_argb8888; }; -struct rgb { double r, g, b; } __attribute__((packed)); +struct rgb { float r, g, b; } __attribute__((packed)); +/* + * Note: we want the cells to be as small as possible. Larger cells + * means fewer scrollback lines (or performance drops due to cache + * misses) */ struct attributes { -#if 0 - bool bold; - bool italic; - bool underline; - bool strikethrough; - bool blink; - bool conceal; - bool reverse; - bool have_foreground; - bool have_background; -#else uint8_t bold:1; uint8_t italic:1; uint8_t underline:1; @@ -61,7 +54,7 @@ struct attributes { uint8_t reverse:1; uint8_t have_foreground:1; uint8_t have_background:1; -#endif + struct rgb foreground; /* Only valid when have_foreground == true */ struct rgb background; /* Only valid when have_background == true */ } __attribute__((packed)); -- cgit v1.3