postgresql/src/backend/optimizer/path
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
..
allpaths.c Fix failure to set correct operator in window run condition 2022-08-05 10:14:00 +12:00
clausesel.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
costsize.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
equivclass.c Fix incorrect tests for SRFs in relation_can_be_sorted_early(). 2022-08-03 17:33:42 -04:00
indxpath.c Use list_copy_head() instead of list_truncate(list_copy(...), ...) 2022-07-13 15:03:47 +12:00
joinpath.c Fix incorrect row estimates used for Memoize costing 2022-05-16 16:07:56 +12:00
joinrels.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
pathkeys.c Improve performance of ORDER BY / DISTINCT aggregates 2022-08-02 23:11:45 +12:00
tidpath.c Update copyright for 2022 2022-01-07 19:04:57 -05:00