diff options
author | Rasmus Villemoes <rv@rasmusvillemoes.dk> | 2016-12-06 19:53:38 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-12-07 15:44:31 -0800 |
commit | 1127b3ced55b97229c55ff0c7585b284e3551a9e (patch) | |
tree | 670aac6ae5864183d3b8672a2cdf563309f258e4 /Documentation/config.txt | |
parent | shallow.c: avoid theoretical pointer wrap-around (diff) | |
download | tgif-1127b3ced55b97229c55ff0c7585b284e3551a9e.tar.xz |
shallow.c: bit manipulation tweaks
First of all, 1 << 31 is technically undefined behaviour, so let's just
use an unsigned literal.
If i is 'signed int' and gcc doesn't know that i is positive, gcc
generates code to compute the C99-mandated values of "i / 32" and "i %
32", which is a lot more complicated than simple a simple shifts/mask.
The only caller of paint_down actually passes an "unsigned int" value,
but the prototype of paint_down causes (completely well-defined)
conversion to signed int, and gcc has no way of knowing that the
converted value is non-negative. Just make the id parameter unsigned.
In update_refstatus, the change in generated code is much smaller,
presumably because gcc is smart enough to see that i starts as 0 and is
only incremented, so it is allowed (per the UD of signed overflow) to
assume that i is always non-negative. But let's just help less smart
compilers generate good code anyway.
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/config.txt')
0 files changed, 0 insertions, 0 deletions