Vectorization of some functions and improving pg_list interface

Поиск
Список
Период
Сортировка
От Maxim Orlov
Тема Vectorization of some functions and improving pg_list interface
Дата
Msg-id CACG=ezasBfMiXgx=O_n3oigCk0JADG6RKimrzj7yDPGqQG9MSw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Vectorization of some functions and improving pg_list interface
Re: Vectorization of some functions and improving pg_list interface
Список pgsql-hackers
Hi!

Recently, I've been playing around with pg_lists and realize how annoying (maybe, I was a bit tired) some stuff related to the lists.
For an example, see this code
List     *l1 = list_make4(1, 2, 3, 4),
         *l2 = list_make4(5, 6, 7, 8),
         *l3 = list_make4(9, 0, 1, 2);
ListCell *lc1, *lc2, *lc3;

forthree(lc1, l1, lc2, l2, lc3, l3) {
...
}

list_free(l1);
list_free(l2);
list_free(l3);

There are several questions:
1) Why do I need to specify the number of elements in the list in the function name?
    Compiler already knew how much arguments do I use.
2) Why I have to call free for every list? I don't know how to call it right, for now I call it vectorization.
    Why not to use simple wrapper to "vectorize" function args?

So, my proposal is:
1) Add a simple macro to "vectorize" functions.
2) Use this macro to "vectorize" list_free and list_free_deep functions.
3) Use this macro to "vectorize" bms_free function.
4) "Vectorize" list_makeN functions.

For this V1 version, I do not remove all list_makeN calls in order to reduce diff, but I'll address
this in future, if it will be needed.

In my view, one thing still waiting to be improved if foreach loop. It is not very handy to have a bunch of
similar calls foreach, forboth, forthree and etc. It will be ideal to have single foreach interface, but I don't know how
to do it without overall interface of the loop.

Any opinions are very welcome!

--
Best regards,
Maxim Orlov.
Вложения

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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Use FD_CLOEXEC on ListenSockets (was Re: Refactoring backend fork+exec code)
Следующее
От: Chapman Flack
Дата:
Сообщение: Re: Vectorization of some functions and improving pg_list interface