aboutsummaryrefslogtreecommitdiffstats
path: root/ui-refs.c
diff options
context:
space:
mode:
authorGravatar Jason A. Donenfeld <Jason@zx2c4.com>2014-02-27 00:57:15 (JST)
committerGravatar Jason A. Donenfeld <Jason@zx2c4.com>2014-02-27 00:57:15 (JST)
commit493061102653ac6483dc3c9649c726318e2488b6 (patch)
treed84a326c43c297d240b6d26e7d82075fa9fd8c28 /ui-refs.c
parent3e9578e9a3393eaebc658ad650a3241bf1930176 (diff)
downloadcgit-493061102653ac6483dc3c9649c726318e2488b6.zip
cgit-493061102653ac6483dc3c9649c726318e2488b6.tar.gz
ui-refs: simplify cmp_age logic
The check in parse_user that eventually makes it into committer_date and tagger_date is: else if (mode == 3 && isdigit(*p)) { *date = atol(p); mode++; } Since isdigit('-') is always false, date will never be negative. Thus the sign of this function: static int cmp_age(int age1, int age2) { if (age1 != 0 && age2 != 0) return age2 - age1; if (age1 == 0 && age2 == 0) return 0; if (age1 == 0) return +1; return -1; } Will always be the same as the sign of this function: static inline int cmp_age(int age1, int age2) { return age2 - age1; } Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Idea-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'ui-refs.c')
-rw-r--r--ui-refs.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/ui-refs.c b/ui-refs.c
index e8e308e..0da063f 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -11,18 +11,10 @@
11#include "html.h" 11#include "html.h"
12#include "ui-shared.h" 12#include "ui-shared.h"
13 13
14static int cmp_age(int age1, int age2) 14static inline int cmp_age(int age1, int age2)
15{ 15{
16 if (age1 != 0 && age2 != 0) 16 /* age1 and age2 are assumed to be non-negative */
17 return age2 - age1; 17 return age2 - age1;
18
19 if (age1 == 0 && age2 == 0)
20 return 0;
21
22 if (age1 == 0)
23 return +1;
24
25 return -1;
26} 18}
27 19
28static int cmp_ref_name(const void *a, const void *b) 20static int cmp_ref_name(const void *a, const void *b)