Re: strange case of "if ((a & b))"

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Peter Smith <smithpb2250@gmail.com>, Bruce Momjian <bruce@momjian.us>, pgsql-hackers@lists.postgresql.org
Date: 2021-09-07T05:59:58Z
Lists: pgsql-hackers
On Sun, Sep 05, 2021 at 07:11:10PM -0500, Justin Pryzby wrote:
> I revised the patch based on these comments.  I think my ternary patch already
> excluded the cases that test something other than a boolean.

In 0002, everything is a boolean expression except for
SpGistPageStoresNulls() and GistPageIsLeaf().  So that's a good
cleanup overall.

-   pathnode->parallel_aware = parallel_workers > 0 ? true : false;
+   pathnode->parallel_aware = parallel_workers > 0;
I also prefer that we keep the parenthesis for such things.  That's
more readable and easier to reason about.
--
Michael

Commits

  1. Clean up more code using "(expr) ? true : false"

  2. Clean up some code using "(expr) ? true : false"