forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2d5fe5b
Avoid using list_length() to test for empty list.
The standard way to check for list emptiness is to compare theList pointer to NIL; our list code goes out of its way to ensurethat that is the only representation of an empty list. (Anacceptable alternative is a plain boolean test for non-nullpointer, but explicit mention of NIL is usually preferable.)Various places didn't get that memo and expressed the conditionwith list_length(), which might not be so bad except that therewere such a variety of ways to check it exactly: equal to zero,less than or equal to zero, less than one, yadda yadda. In thename of code readability, let's standardize all those spellingsas "list == NIL" or "list != NIL". (There's probably somemicroscopic efficiency gain too, though few of these look to beat all performance-critical.)A very small number of cases were left as-is because they seemedmore consistent with other adjacent list_length tests that way.Peter Smith, with bikeshedding from a number of usDiscussion:https://postgr.es/m/CAHut+PtQYe+ENX5KrONMfugf0q6NHg4hR5dAhqEXEc2eefFeig@mail.gmail.com1 parente9b65b1 commit2d5fe5b
File tree
28 files changed
+47
-48
lines changed- src
- backend
- catalog
- commands
- executor
- libpq
- optimizer
- path
- plan
- partitioning
- replication
- logical
- pgoutput
- rewrite
- statistics
- storage/lmgr
- utils/adt
- test/modules/test_ddl_deparse
28 files changed
+47
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2186 | 2186 | | |
2187 | 2187 | | |
2188 | 2188 | | |
2189 | | - | |
| 2189 | + | |
2190 | 2190 | | |
2191 | 2191 | | |
2192 | 2192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
947 | 947 | | |
948 | 948 | | |
949 | 949 | | |
950 | | - | |
| 950 | + | |
951 | 951 | | |
952 | 952 | | |
953 | 953 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1143 | 1143 | | |
1144 | 1144 | | |
1145 | 1145 | | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1149 | 1149 | | |
1150 | 1150 | | |
1151 | 1151 | | |
| |||
1616 | 1616 | | |
1617 | 1617 | | |
1618 | 1618 | | |
1619 | | - | |
| 1619 | + | |
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| |||
1209 | 1209 | | |
1210 | 1210 | | |
1211 | 1211 | | |
1212 | | - | |
| 1212 | + | |
1213 | 1213 | | |
1214 | 1214 | | |
1215 | 1215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
851 | | - | |
| 851 | + | |
852 | 852 | | |
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
856 | | - | |
| 856 | + | |
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
| |||
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
874 | | - | |
| 874 | + | |
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2097 | 2097 | | |
2098 | 2098 | | |
2099 | 2099 | | |
2100 | | - | |
| 2100 | + | |
2101 | 2101 | | |
2102 | 2102 | | |
2103 | 2103 | | |
| |||
16264 | 16264 | | |
16265 | 16265 | | |
16266 | 16266 | | |
16267 | | - | |
16268 | | - | |
| 16267 | + | |
| 16268 | + | |
16269 | 16269 | | |
16270 | 16270 | | |
16271 | | - | |
| 16271 | + | |
16272 | 16272 | | |
16273 | 16273 | | |
16274 | 16274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3503 | 3503 | | |
3504 | 3504 | | |
3505 | 3505 | | |
3506 | | - | |
| 3506 | + | |
3507 | 3507 | | |
3508 | 3508 | | |
3509 | 3509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | | - | |
| 688 | + | |
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
| |||
0 commit comments
Comments
(0)