Re: make BuiltinTrancheNames less ugly

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: make BuiltinTrancheNames less ugly
Date: 2024-01-23 10:33:50
Message-ID: 31066a40-3844-4238-98a4-5eec3f8a598e@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23/01/2024 12:25, Alvaro Herrera wrote:
> 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.

Idea 2 seems pretty straightforward, +1 for that.

--
Heikki Linnakangas
Neon (https://neon.tech)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2024-01-23 10:38:22 Re: psql: Allow editing query results with \gedit
Previous Message Alvaro Herrera 2024-01-23 10:25:25 make BuiltinTrancheNames less ugly