forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit14dd0f2
committed
Add macros for looping through a List without a ListCell.
Many foreach loops only use the ListCell pointer to retrieve thecontent of the cell, like so: ListCell *lc; foreach(lc, mylist) { int myint = lfirst_int(lc); ... }This commit adds a few convenience macros that automaticallydeclare the loop variable and retrieve the current cell's contents.This allows us to rewrite the previous loop like this: foreach_int(myint, mylist) { ... }This commit also adjusts a few existing loops in order to addcoverage for the new/adjusted macros. There is presently no planto bulk update all foreach loops, as that could introduce asignificant amount of back-patching pain. Instead, these macrosare primarily intended for use in new code.Author: Jelte Fennema-NioReviewed-by: David Rowley, Alvaro Herrera, Vignesh C, Tom LaneDiscussion:https://postgr.es/m/CAGECzQSwXKnxGwW1_Q5JE%2B8Ja20kyAbhBHO04vVrQsLcDciwXA%40mail.gmail.com1 parent5e8674d commit14dd0f2
File tree
5 files changed
+71
-26
lines changed- src
- backend
- executor
- replication
- logical
- pgoutput
- include/nodes
5 files changed
+71
-26
lines changedLines changed: 3 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
219 |
| - | |
220 | 219 |
| |
221 | 220 |
| |
222 | 221 |
| |
| |||
250 | 249 |
| |
251 | 250 |
| |
252 | 251 |
| |
253 |
| - | |
| 252 | + | |
254 | 253 |
| |
255 |
| - | |
256 |
| - | |
257 | 254 |
| |
258 | 255 |
| |
259 | 256 |
| |
| |||
265 | 262 |
| |
266 | 263 |
| |
267 | 264 |
| |
268 |
| - | |
| 265 | + | |
269 | 266 |
| |
270 |
| - | |
| 267 | + | |
271 | 268 |
| |
272 | 269 |
| |
273 | 270 |
| |
|
Lines changed: 1 addition & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
746 | 746 |
| |
747 | 747 |
| |
748 | 748 |
| |
749 |
| - | |
750 | 749 |
| |
751 |
| - | |
| 750 | + | |
752 | 751 |
| |
753 |
| - | |
754 | 752 |
| |
755 | 753 |
| |
756 | 754 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1036 | 1036 |
| |
1037 | 1037 |
| |
1038 | 1038 |
| |
1039 |
| - | |
| 1039 | + | |
1040 | 1040 |
| |
1041 |
| - | |
| 1041 | + | |
1042 | 1042 |
| |
1043 |
| - | |
| 1043 | + | |
1044 | 1044 |
| |
1045 | 1045 |
| |
1046 | 1046 |
| |
|
Lines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2234 | 2234 |
| |
2235 | 2235 |
| |
2236 | 2236 |
| |
2237 |
| - | |
2238 | 2237 |
| |
2239 | 2238 |
| |
2240 | 2239 |
| |
| |||
2247 | 2246 |
| |
2248 | 2247 |
| |
2249 | 2248 |
| |
2250 |
| - | |
| 2249 | + | |
2251 | 2250 |
| |
2252 |
| - | |
| 2251 | + | |
2253 | 2252 |
| |
2254 | 2253 |
| |
2255 | 2254 |
| |
2256 | 2255 |
| |
2257 | 2256 |
| |
2258 |
| - | |
| 2257 | + | |
2259 | 2258 |
| |
2260 | 2259 |
| |
2261 | 2260 |
| |
|
Lines changed: 61 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
381 | 381 |
| |
382 | 382 |
| |
383 | 383 |
| |
384 |
| - | |
| 384 | + | |
| 385 | + | |
385 | 386 |
| |
386 |
| - | |
387 |
| - | |
388 |
| - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
389 | 390 |
| |
390 |
| - | |
391 |
| - | |
392 |
| - | |
| 391 | + | |
| 392 | + | |
393 | 393 |
| |
394 | 394 |
| |
395 | 395 |
| |
396 |
| - | |
397 |
| - | |
| 396 | + | |
| 397 | + | |
398 | 398 |
| |
399 | 399 |
| |
400 | 400 |
| |
401 | 401 |
| |
402 | 402 |
| |
403 |
| - | |
| 403 | + | |
404 | 404 |
| |
405 | 405 |
| |
406 | 406 |
| |
| |||
452 | 452 |
| |
453 | 453 |
| |
454 | 454 |
| |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
455 | 506 |
| |
456 | 507 |
| |
457 | 508 |
| |
|
0 commit comments
Comments
(0)