From 4b0e9a6bee9699b9edce6b9afc6a66734ce00a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 7 Mar 2021 11:49:15 +0100 Subject: [PATCH] =?UTF-8?q?sixel:=20remove=20=E2=80=98max=5Fcol=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image width *is* the maximum number of columns we’ve seen. --- sixel.c | 15 +++------------ terminal.h | 1 - 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/sixel.c b/sixel.c index 4807f2a8..507caeee 100644 --- a/sixel.c +++ b/sixel.c @@ -39,7 +39,6 @@ sixel_init(struct terminal *term) term->sixel.pos = (struct coord){0, 0}; term->sixel.row_byte_ofs = 0; term->sixel.color_idx = 0; - term->sixel.max_col = 0; term->sixel.param = 0; term->sixel.param_idx = 0; memset(term->sixel.params, 0, sizeof(term->sixel.params)); @@ -830,7 +829,6 @@ sixel_unhook(struct terminal *term) term->sixel.image.data = NULL; term->sixel.image.width = 0; term->sixel.image.height = 0; - term->sixel.max_col = 0; term->sixel.pos = (struct coord){0, 0}; free(term->sixel.private_palette); @@ -923,12 +921,9 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel) int width = term->sixel.image.width; - if (term->sixel.pos.col >= width) { - width = max( - term->sixel.image.width, - max(term->sixel.max_col, term->sixel.pos.col + 1)); - - if (!resize(term, width, term->sixel.image.height)) + if (unlikely(term->sixel.pos.col >= width)) { + width = term->sixel.pos.col + 1; + if (unlikely(!resize(term, width, term->sixel.image.height))) return; } @@ -971,14 +966,10 @@ decsixel(struct terminal *term, uint8_t c) break; case '$': - if (term->sixel.pos.col > term->sixel.max_col) - term->sixel.max_col = term->sixel.pos.col; term->sixel.pos.col = 0; break; case '-': - if (term->sixel.pos.col > term->sixel.max_col) - term->sixel.max_col = term->sixel.pos.col; term->sixel.pos.row += 6; term->sixel.pos.col = 0; term->sixel.row_byte_ofs += term->sixel.image.width * 6; diff --git a/terminal.h b/terminal.h index 2a8bb6f9..81893e34 100644 --- a/terminal.h +++ b/terminal.h @@ -523,7 +523,6 @@ struct terminal { struct coord pos; /* Current sixel coordinate */ size_t row_byte_ofs; /* Byte position into image, for current row */ int color_idx; /* Current palette index */ - int max_col; /* Largest column index we've seen (aka the image width) */ uint32_t *private_palette; /* Private palette, used when private mode 1070 is enabled */ uint32_t *shared_palette; /* Shared palette, used when private mode 1070 is disabled */ uint32_t *palette; /* Points to either private_palette or shared_palette */