Re: Add new for_each macros for iterating over a List that do not require ListCell pointer

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
Date: 2023-12-20 06:51:05
Message-ID: CALDaNm2Nx68mz1jgCJpE4s-9AmLdcNwg6a87_o7RAvECnbxErA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 19 Dec 2023 at 21:22, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
>
> On Tue, Dec 19, 2023 at 03:44:43PM +0100, Jelte Fennema-Nio wrote:
> > On Tue, 19 Dec 2023 at 11:59, vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >> I noticed that this change can be done in several other places too.
> >
> > My guess would be that ~90% of all existing foreach loops in the
> > codebase can be easily rewritten (and simplified) using these new
> > macros. So converting all of those would likely be quite a bit of
> > work. In patch 0003 I only converted a few of them to get some
> > coverage of the new macros and show how much simpler the usage of them
> > is.
>
> I'm not sure we should proceed with rewriting most/all eligible foreach
> loops. I think it's fine to use the new macros in new code or to update
> existing loops in passing when changing nearby code, but rewriting
> everything likely just introduces back-patching pain in return for little
> discernible gain.

+1 for this. Let's just provide the for_each macros to be used for new code.
This means that the
0003-Use-new-foreach_xyz-macros-in-a-few-places.patch will not be
present in the final patch right?

Regards,
Vignesh

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Drouvot, Bertrand 2023-12-20 07:16:09 Re: Function to get invalidation cause of a replication slot.
Previous Message John Naylor 2023-12-20 06:48:22 Re: Change GUC hashtable to use simplehash?