Propose a new function - list_is_empty

Поиск
Список
Период
Сортировка
От Peter Smith
Тема Propose a new function - list_is_empty
Дата
Msg-id CAHut+PtQYe+ENX5KrONMfugf0q6NHg4hR5dAhqEXEc2eefFeig@mail.gmail.com
обсуждение исходный текст
Ответы Re: Propose a new function - list_is_empty  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
During a recent code review I was going to suggest that some new code
would be more readable if the following:
if (list_length(alist) == 0) ...

was replaced with:
if (list_is_empty(alist)) ...

but then I found that actually no such function exists.

~~~

Searching the PG source found many cases using all kinds of
inconsistent ways to test for empty Lists:
e.g.1 if (list_length(alist) > 0)
e.g.2 if (list_length(alist) == 0)
e.g.3 if (list_length(alist) != 0)
e.g.4 if (list_length(alist) >= 1)
e.g.5 if (list_length(alist) < 1)

Of course, all of them work OK as-is, but by using list_is_empty all
those can be made consistent and often also more readable as to the
code intent.

Patch 0001 adds a new function 'list_is_empty'.
Patch 0002 makes use of it.

Thoughts?

------
Kind Regards,
Peter Smith.
Fujitsu Australia

Вложения

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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Cleaning up historical portability baggage
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Propose a new function - list_is_empty