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>
			
			
Esse commit está contido em:
		
							
								
								
									
										14
									
								
								ui-refs.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ui-refs.c
									
									
									
									
									
								
							| @@ -11,18 +11,10 @@ | ||||
| #include "html.h" | ||||
| #include "ui-shared.h" | ||||
|  | ||||
| static int cmp_age(int age1, int age2) | ||||
| static inline 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; | ||||
| 	/* age1 and age2 are assumed to be non-negative */ | ||||
| 	return age2 - age1; | ||||
| } | ||||
|  | ||||
| static int cmp_ref_name(const void *a, const void *b) | ||||
|   | ||||
		Referência em uma nova issue
	
	Block a user
	 Jason A. Donenfeld
					Jason A. Donenfeld