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