From 5e9d68695c05d4be03ac7b83dd0eabc42bb7fefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 27 Jun 2023 16:21:26 +0200 Subject: [PATCH] sixel: add_ar_11(): manually unroll loop This generates both smaller, and faster code --- sixel.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sixel.c b/sixel.c index ec0cbc5a..31a55a69 100644 --- a/sixel.c +++ b/sixel.c @@ -1360,15 +1360,26 @@ sixel_add_ar_11(struct terminal *term, int col, int width, uint32_t color, xassert(term->sixel.pos.row < term->sixel.image.height); xassert(term->sixel.pan == 1); - size_t ofs = term->sixel.row_byte_ofs + col; + const size_t ofs = term->sixel.row_byte_ofs + col; uint32_t *data = &term->sixel.image.data[ofs]; - for (int i = 0; i < 6; i++, sixel >>= 1, data += width) { - if (sixel & 1) - *data = color; - } - - xassert(sixel == 0); + if (sixel & 0x01) + *data = color; + data += width; + if (sixel & 0x02) + *data = color; + data += width; + if (sixel & 0x04) + *data = color; + data += width; + if (sixel & 0x08) + *data = color; + data += width; + if (sixel & 0x10) + *data = color; + data += width; + if (sixel & 0x20) + *data = color; } static void