Proposal: Make use of C99 designated initialisers for nulls/valuesarrays

Поиск
Список
Период
Сортировка
От Smith, Peter
Тема Proposal: Make use of C99 designated initialisers for nulls/valuesarrays
Дата
Msg-id 201DD0641B056142AC8C6645EC1B5F62014B919631@SYD1217
обсуждение исходный текст
Ответы Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Amit Kapila <amit.kapila16@gmail.com>)
Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Isaac Morland <isaac.morland@gmail.com>)
Список pgsql-hackers
Dear Hackers,

I have identified some OSS code which maybe can make use of C99 designated initialisers for nulls/values arrays.

~

Background:
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.
Actually, this mechanism is already being used in some of the existing OSS code. This patch/proposal just propagates
thesame idea to all other similar places I could find. 

~

Result:
Less code. Removes ~200 unnecessary memsets.
More consistent initialisation.

~

Typical Example:
Before:
    Datum        values[Natts_pg_attribute];
    bool        nulls[Natts_pg_attribute];
    ...
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
After:
    Datum        values[Natts_pg_attribute] = {0};
    bool        nulls[Natts_pg_attribute] = {0};


---
[1] REF C99 [$6.7.8/21] If there are fewer initializers in a brace-enclosed list than there are elements or members of
anaggregate,  
or fewer characters in a string literal used to initialize an array of known size than there are elements in the array,

the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration

~

Please refer to the attached patch.

Kind Regards,

---
Peter Smith
Fujitsu Australia





Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Declaring a strict function returns not null / eval speed
Следующее
От: "Moon, Insung"
Дата:
Сообщение: Re: Transparent Data Encryption (TDE) and encrypted files