On 03/08/2020 15.44, Gregory Burd wrote:
Sjoerd,
Nice explanation, so if they are both correct and one avoids unnecessary work (even just a tiny bit) why not adjust the code to add your explanation as a comment and use the more efficient version?
In the one case you have an extra evaluation (of a bit), in the other case you have possibly a jump. If the jump cannot be predicted by the CPU, it is definitely more expensive than the extra evaluation.
-greg
On Mon, Aug 3, 2020 at 3:02 AM Sjoerd Mullender
mailto:sjoerd@monetdb.org> wrote: 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).
On 01/08/2020 20.54, Ranier Vilela wrote: > Hi, > > At gdk\gdk_bat.c (line 1384) > variable b->type is bool > > Would be a typo? > if (((b->ttype != TYPE_void) & b->tkey) && b->batCount > 1) { > Should be: > if (((b->ttype != TYPE_void) && b->tkey) && b->batCount > 1) { > > regards, > Ranier Vilela > > _______________________________________________ > developers-list mailing list > developers-list@monetdb.org mailto:developers-list@monetdb.org > https://www.monetdb.org/mailman/listinfo/developers-list >
-- Sjoerd Mullender _______________________________________________ developers-list mailing list developers-list@monetdb.org mailto:developers-list@monetdb.org https://www.monetdb.org/mailman/listinfo/developers-list
_______________________________________________ developers-list mailing list developers-list@monetdb.org https://www.monetdb.org/mailman/listinfo/developers-list
-- Sjoerd Mullender