On 2023-Oct-24, Jelte Fennema wrote: > Many usages of the foreach macro in the Postgres codebase only use the > ListCell variable to then get its value. This adds macros that > simplify iteration code for that very common use case. Instead of > passing a ListCell you can pass a variable of the type of its > contents. This IMHO improves readability of the code by reducing the > total amount of code while also essentially forcing the use of useful > variable names.
+1 for getting rid of useless "lc" variables. Looking at for_each_ptr() I think it may be cleaner to follow palloc_object()'s precedent and make it foreach_object() instead (I have no love for the extra underscore, but I won't object to it either). And like foreach_node, have it receive a type name to add a cast to. I'd imagine something like SubscriptionRelState *rstate; foreach_object(SubscriptionRelState *, rstate, table_states_not_ready) { -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/