aboutsummaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorN-R-K <nrk@disroot.org>2022-04-27 03:25:11 +0200
committerGitHub <noreply@github.com>2022-04-27 03:25:11 +0200
commit29c6b1456e8bb46fbee0e8ea962553cb9f1230a3 (patch)
tree99f72eff053384c0251cac83722ceb5653ed80bf /image.c
parent7fb8a61c47b8968f3da7decaefbe55b621e68420 (diff)
downloadnsxiv-29c6b1456e8bb46fbee0e8ea962553cb9f1230a3.tar.zst
code-style: reduce some unnecessary if-elses (#261)
also change the condition inside img_frame_animate() to check for positive value rather than comparing against 0.
Diffstat (limited to 'image.c')
-rw-r--r--image.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/image.c b/image.c
index ba5b1fe..2904887 100644
--- a/image.c
+++ b/image.c
@@ -898,23 +898,15 @@ bool img_frame_navigate(img_t *img, int d)
return false;
d += img->multi.sel;
- if (d < 0)
- d = 0;
- else if (d >= img->multi.cnt)
- d = img->multi.cnt - 1;
+ d = MAX(0, MIN(d, img->multi.cnt - 1));
return img_frame_goto(img, d);
}
bool img_frame_animate(img_t *img)
{
- if (img->multi.cnt == 0)
- return false;
-
- if (img->multi.sel + 1 >= img->multi.cnt)
- img_frame_goto(img, 0);
+ if (img->multi.cnt > 0)
+ return img_frame_goto(img, (img->multi.sel + 1) % img->multi.cnt);
else
- img_frame_goto(img, img->multi.sel + 1);
- img->dirty = true;
- return true;
+ return false;
}