Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Date
Msg-id 4147.1569946628@sss.pgh.pa.us
Whole thread Raw
In response to Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
>>> On Tue, Oct 1, 2019 at 1:25 PM Smith, Peter <peters@fast.au.fujitsu.com> wrote:
>>>> There are lots of tuple operations where arrays of values and flags are being passed.
>>>> Typically these arrays are being previously initialised 0/false by memset.
>>>> By modifying code to use C99 designated initialiser syntax [1], most of these memsets can become redundant.

> I like it!

FYI, I checked into whether this would result in worse generated code.
In the one place I checked (InsertPgAttributeTuple, which hopefully
is representative), I got *exactly the same* assembly code before
and after, on both a somewhat-aging gcc and fairly modern clang.
Hadn't quite expected that, but it removes any worries about whether
we might be losing anything.

Note though that InsertPgAttributeTuple uses memset(), while some of
these other places use MemSet().  The code I see being generated for
MemSet() is also the same(!) on clang, but it is different and
probably worse on gcc.  I wonder if it isn't time to kick MemSet to
the curb.  We have not re-evaluated that macro in more than a dozen
years, and compilers have surely changed.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "REIX, Tony"
Date:
Subject: RE: Shared Memory: How to use SYSV rather than MMAP ?
Next
From: Bruce Momjian
Date:
Subject: Re: Value of Transparent Data Encryption (TDE)