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

Поиск
Список
Период
Сортировка
От Jelte Fennema-Nio
Тема Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
Дата
Msg-id CAGECzQQW7coOKjFXZq2A6mEjrvUB-GGmhiEpqsUCehZzY8frXw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add new for_each macros for iterating over a List that do not require ListCell pointer  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Ответы Re: Add new for_each macros for iterating over a List that do not require ListCell pointer  (vignesh C <vignesh21@gmail.com>)
Список pgsql-hackers
The more I think about it and look at the code, the more I like the
usage of the loop style proposed in the previous 0003 patch (which
automatically declares a loop variable for the scope of the loop using
a second for loop).

I did some testing on godbolt.org and both versions of the macros
result in the same assembly when compiling with -O2 (and even -O1)
when compiling with ancient versions of gcc (5.1) and clang (3.0):
https://godbolt.org/z/WqfTbhe4e

So attached is now an updated patchset that only includes these even
easier to use foreach macros. I also updated some of the comments and
moved modifying foreach_delete_current and foreach_current_index to
their own commit.

On Thu, 14 Dec 2023 at 16:54, Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
>
> On Fri, 1 Dec 2023 at 05:20, Nathan Bossart <nathandbossart@gmail.com> wrote:
> > Could we simplify it with something like the following?
>
> Great suggestion! Updated the patchset accordingly.
>
> This made it also easy to change the final patch to include the
> automatic scoped declaration logic for all of the new macros. I quite
> like how the calling code changes to not have to declare the variable.
> But it's definitely a larger divergence from the status quo than
> without patch 0003. So I'm not sure if it's desired.
>
> Finally, I also renamed the functions to use foreach instead of
> for_each, since based on this thread that seems to be the generally
> preferred naming.

Вложения

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

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: Postgres picks suboptimal index after building of an extended statistics
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Remove MSVC scripts from the tree