Re: Propose a new function - list_is_empty
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Smith <smithpb2250@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-08-16T13:47:56Z
Lists: pgsql-hackers
On Mon, Aug 15, 2022 at 9:28 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Peter Smith <smithpb2250@gmail.com> writes: > > 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. > > That's because the *correct* way to write it is either "alist == NIL" > or just "!alist". I think the alist == NIL (or alist != NIL) style often makes the code easier to read. I recommend we standardize on that one. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Avoid using list_length() to test for empty list.
- efd0c16becbf 16.0 landed