From 6e963dbf6837094f93921f47cdc83aada244be6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 7 Mar 2021 15:45:39 +0100 Subject: [PATCH] sixel: add: calculate absolute row no inside the loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This results in the same number of instructions inside the loop, with a ‘lea’ instead of a ‘mov’, but simplifies the post-loop logic to update the global state. --- sixel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sixel.c b/sixel.c index 4f03143d..7fb9be0d 100644 --- a/sixel.c +++ b/sixel.c @@ -1007,10 +1007,11 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel) uint32_t *data = &term->sixel.image.data[ofs]; int max_non_empty_row = 0; + int row = term->sixel.pos.row; for (int i = 0; i < 6; i++, sixel >>= 1, data += width) { if (sixel & 1) { - max_non_empty_row = i; *data = color; + max_non_empty_row = row + i; } } @@ -1019,7 +1020,7 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel) term->sixel.max_non_empty_row_no = max( term->sixel.max_non_empty_row_no, - term->sixel.pos.row + max_non_empty_row); + max_non_empty_row); } static void