From 0a5a6cb7fa58577989716976a3430a9de4cac860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 4 Oct 2020 19:28:22 +0200 Subject: [PATCH] sixel: scroll up/down: early return when list is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Branch tagged as ‘likely’ for performance reason --- sixel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sixel.c b/sixel.c index ee34df0a..76b42b25 100644 --- a/sixel.c +++ b/sixel.c @@ -242,6 +242,9 @@ out: void sixel_scroll_up(struct terminal *term, int rows) { + if (likely(tll_length(term->grid->sixel_images) == 0)) + return; + tll_rforeach(term->grid->sixel_images, it) { struct sixel *six = &it->item; @@ -269,6 +272,9 @@ sixel_scroll_up(struct terminal *term, int rows) void sixel_scroll_down(struct terminal *term, int rows) { + if (likely(tll_length(term->grid->sixel_images) == 0)) + return; + assert(term->grid->num_rows >= rows); tll_foreach(term->grid->sixel_images, it) {