3 Aug
2020
3 Aug
'20
1:19 p.m.
Em seg., 3 de ago. de 2020 às 04:02, Sjoerd Mullender
Either way is correct. The first form evaluates both (b->ttype != TYPE_void) and b->tkey, both of which result in either 0 or 1. The single & does a bit-wise AND on those two values and results in 1 if both sides evaluated to 1. In the second form, if first part evaluates to 0, b->tkey is not evaluated, and if the first part evaluates to 1, the second part is also evaluated. The restult, again, is only 1 if both sides evaluate to 1.
So the difference is whether or not b->tkey is evaluated, and evaluating that is cheap (it's a bool value).
Thanks for the explanation. regards, Ranier Vilela