Re: Remove redundant initializations

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Remove redundant initializations
Date: 2021-06-28 11:57:24
Message-ID: EDB8362F-3CF7-4883-A811-F6443481AC63@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 28 Jun 2021, at 11:59, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
>
> There are certain parts of code that laboriously initialize every field of a struct to (some spelling of) zero, even though the whole struct was just zeroed (by makeNode() or memset()) a few lines earlier. Besides being redundant, I find this hard to read in some situations because it's then very hard to tell what is different between different cases or branches. The attached patch cleans up most of that. I left alone instances where there are (nontrivial) comments attached to the initializations or where there appeared to be some value in maintaining symmetry. But a lot of it was just plain useless code, some clearly copy-and-pasted repeatedly.

I personally sort of like the initializations of Lists like the one below, even
if redundant, since they then clearly stand out as being Lists.

- fk_trigger->args = NIL;

Just a matter of personal preference, but I find that those aid readability.

--
Daniel Gustafsson https://vmware.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2021-06-28 12:08:31 Re: Deadlock risk while inserting directly into partition?
Previous Message David Rowley 2021-06-28 11:46:30 Re: Deadlock risk while inserting directly into partition?