Krolyxon
Commit 29c6b14

Branches

Refs →

nsxiv29c6b14

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.
Author
N-R-K
Date
2022-04-27 01:25 +0000
Committer
GitHub · 2022-04-27 01:25 +0000
Parent
7fb8a61
Commit
29c6b1456e8bb46fbee0e8ea962553cb9f1230a3

+5 −16

2 files changed

  1. M commands.c +1 −4
  2. M image.c +4 −12
M commands.c View
@@ -273,10 +273,7 @@ bool ci_navigate(arg_t n)
273273 if (prefix > 0)
274274 n *= prefix;
275275 n += fileidx;
276− if (n < 0)
277− n = 0;
278− if (n >= filecnt)
279− n = filecnt - 1;
276+ n = MAX(0, MIN(n, filecnt - 1));
280277
281278 if (n != fileidx) {
282279 load_image(n);
M image.c View
@@ -898,23 +898,15 @@ bool img_frame_navigate(img_t *img, int d)
898898 return false;
899899
900900 d += img->multi.sel;
901− if (d < 0)
902− d = 0;
903− else if (d >= img->multi.cnt)
904− d = img->multi.cnt - 1;
901+ d = MAX(0, MIN(d, img->multi.cnt - 1));
905902
906903 return img_frame_goto(img, d);
907904 }
908905
909906 bool img_frame_animate(img_t *img)
910907 {
911− if (img->multi.cnt == 0)
912− return false;
913−
914− if (img->multi.sel + 1 >= img->multi.cnt)
915− img_frame_goto(img, 0);
908+ if (img->multi.cnt > 0)
909+ return img_frame_goto(img, (img->multi.sel + 1) % img->multi.cnt);
916910 else
917− img_frame_goto(img, img->multi.sel + 1);
918− img->dirty = true;
919− return true;
911+ return false;
920912 }