make BuiltinTrancheNames less ugly

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: make BuiltinTrancheNames less ugly
Date: 2024-01-23 10:25:25
Message-ID: 202401231025.gbv4nnte5fmm@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This array of tranche names is looking pretty ugly these days, and it'll
get worse as we add more members to it. I propose to use C99 designated
initializers, like we've done for other arrays. Patch attached.

The way I've coded in this patch, it means the array will now have 52
NULL pointers at the beginning. I don't think this is a big deal and
makes the code prettier. I see two alternatives:

1. Avoid all those NULLs by making each definition uglier (subtract
NUM_INDIVIDUAL_LWLOCKS from each array index) _and_ the usage of the
array by subtracting the same amount. This saves 208 bytes at the
expense of making the code worse.

2. More invasively, rework generate-lwlocknames.pl so that both lwlocks
and these builtin tranche names appear in a single array. (We could do
so by #include'ing lwlocknames.c at the top of the array).

Now, having written this proposal, I'm leaning towards idea 2 myself,
but since the patch here is less invasive, it seems worth having as
evidence.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"People get annoyed when you try to debug them." (Larry Wall)

Attachment Content-Type Size
0001-Use-designated-initializers-for-BuiltinTrancheNames.patch text/x-diff 4.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2024-01-23 10:33:50 Re: make BuiltinTrancheNames less ugly
Previous Message Peter Eisentraut 2024-01-23 09:58:50 Re: Sequence Access Methods, round two