postgresql/src/backend/rewrite
Tom Lane efd0c16bec Avoid using list_length() to test for empty list.
The standard way to check for list emptiness is to compare the
List pointer to NIL; our list code goes out of its way to ensure
that that is the only representation of an empty list.  (An
acceptable alternative is a plain boolean test for non-null
pointer, but explicit mention of NIL is usually preferable.)

Various places didn't get that memo and expressed the condition
with list_length(), which might not be so bad except that there
were such a variety of ways to check it exactly: equal to zero,
less than or equal to zero, less than one, yadda yadda.  In the
name of code readability, let's standardize all those spellings
as "list == NIL" or "list != NIL".  (There's probably some
microscopic efficiency gain too, though few of these look to be
at all performance-critical.)

A very small number of cases were left as-is because they seemed
more consistent with other adjacent list_length tests that way.

Peter Smith, with bikeshedding from a number of us

Discussion: https://postgr.es/m/CAHut+PtQYe+ENX5KrONMfugf0q6NHg4hR5dAhqEXEc2eefFeig@mail.gmail.com
2022-08-17 11:12:35 -04:00
..
Makefile SEARCH and CYCLE clauses 2021-02-01 14:32:51 +01:00
rewriteDefine.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
rewriteHandler.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00
rewriteManip.c Don't bother to attach column name lists to RowExprs of named types. 2022-03-17 18:25:44 -04:00
rewriteRemove.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rewriteSearchCycle.c Fix incautious CTE matching in rewriteSearchAndCycle(). 2022-04-23 12:16:12 -04:00
rewriteSupport.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rowsecurity.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00