use DIV_ROUND_UP
Convert code that divides and rounds up to use DIV_ROUND_UP to make the intent clearer and reduce the number of magic constants. Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8c8e978f57
commit
42c78a216e
@ -479,10 +479,9 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len)
|
||||
* We now know we have on the order of 2^len objects, which
|
||||
* expects a collision at 2^(len/2). But we also care about hex
|
||||
* chars, not bits, and there are 4 bits per hex. So all
|
||||
* together we need to divide by 2; but we also want to round
|
||||
* odd numbers up, hence adding one before dividing.
|
||||
* together we need to divide by 2 and round up.
|
||||
*/
|
||||
len = (len + 1) / 2;
|
||||
len = DIV_ROUND_UP(len, 2);
|
||||
/*
|
||||
* For very small repos, we stick with our regular fallback.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user