On 8/3/20 7:29 PM, Ranier Vilela wrote: [...]
I agree with you about trick to gain performance.
But this: if (b->ttype != TYPE_void) & b->tkey)
Is the same write: if (b->key)
These two are the same only when the variable b->ttype contains a value different than TYPE_void. But b->ttype might have the value TYPE_void. In that case the whole expression (b->ttype != TYPE_void) & b->tkey evaluates to 0, even if b->tkey is true. If your example program, accepted ptr as input and sometimes it was NULL, while sometimes it was not NULL, that would be a comparable situation.
And if is correct, was that the original intention?
See: int main () { bool r = true; bool key = true; const char * ptr = "not null"; void * pvoid = NULL;
r = (ptr == pvoid); if (r) printf("true\n"); else printf("false\n");
r = ((ptr == pvoid) & key); if (r) printf("true"); else printf("false"); return 0; }
If you set ptr to NULL then the output is true. Likewise b->ttype is not a constant, and that is why we need to check its value. Sometimes that value will be TYPE_void and sometimes it will be different than TYPE_void. You can try to change the bitwise AND to a logical AND in your example program, to see that there is no difference in the computed values. Best regards, Panos.
Here do not matters key value, always be output is false, be key true or false.
See: https://www.gamedev.net/forums/topic/514727-combining-c-bool-and-bitwise-ope...
regards, Ranier Vilela
_______________________________________________ developers-list mailing list developers-list@monetdb.org https://www.monetdb.org/mailman/listinfo/developers-list