aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-06 18:44:26 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:55 +0000
commit7603ae5dc3aed92663cd8f999bb8159f0e4e46ee (patch)
tree236a8e97afcae81860658179d52324cef8b56e27 /sixel.c
parentsixel: store current row position in pixels, not characters (diff)
sixel: avoid multiplication inside the inner sixel emitter loop
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sixel.c b/sixel.c
index bab34015..40c5d938 100644
--- a/sixel.c
+++ b/sixel.c
@@ -921,13 +921,13 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
return;
}
+ size_t ofs = term->sixel.pos.row * term->sixel.image.width;
+ ofs += term->sixel.pos.col;
+
for (int i = 0; i < 6; i++, sixel >>= 1) {
- if (sixel & 1) {
- size_t pixel_row = term->sixel.pos.row + i;
- size_t stride = term->sixel.image.width;
- size_t idx = pixel_row * stride + term->sixel.pos.col;
- term->sixel.image.data[idx] = color_with_alpha(term, color);
- }
+ if (sixel & 1)
+ term->sixel.image.data[ofs] = color_with_alpha(term, color);
+ ofs += term->sixel.image.width;
}
xassert(sixel == 0);