[FFmpeg-devel] [PATCH 5/5] lavfi: make request_frame() non-recursive.
Nicolas George
george at nsup.org
Tue Dec 1 17:26:23 CET 2015
Le decadi 10 frimaire, an CCXXIV, Hendrik Leppkes a écrit :
> We generally just use ints for boolean properties, any particular
> reason this uses unsigned instead?
Just a matter of personal habit, justified below. But as I look at it, I see
it is rather inconsistent with other fields in the struct that are int
although they really would be better unsigned. Will change.
When it does not matter, I usually use unsigned instead of signed because
that often leaves the compiler more room for optimization. For example,
"type half(type x) { return x / 2; }" compiles into this for unsigned:
movl %edi, %eax
shrl %eax
ret
And this for signed:
movl %edi, %eax
movl $2, %ecx
cltd
idivl %ecx
ret
In other words, "x / 2" can be optimized into "x >> 1" for unsigned, but not
for signed because the rounding is not the same for negative.
I suppose in fact you already knew that. Of course it does not make a
difference here, but I prefer this habit instead of the other way around.
For booleans, I feel that int gives the impression there is a third case,
possibly error: think of ssize_t for the return value of syscalls. And if it
becomes a counter, then it should naturally be unsigned.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151201/acd6212d/attachment.sig>
More information about the ffmpeg-devel
mailing list