Re: Small improvements to pg_list.h's linitial(), lsecond(), lthird() etc macros
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2020-09-28T01:50:23Z
Lists: pgsql-hackers
On Mon, 28 Sep 2020 at 12:58, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > David Rowley <dgrowleyml@gmail.com> writes: > > I'm a bit unsure about llast()'s new double evaluation of the list. > > Perhaps I can add a new inline function named list_last_cell() to get > > around that... Or maybe it doesn't matter. I'm not quite sure what's > > best there. > > Double evaluation bad, especially in a macro that has not had such a > hazard for the last twenty-plus years. > > It might not be worth mucking with llast, as it's not used very heavily > I believe. But if it is, then let's add another inline function. Thanks for having a look at this. I changed things around to make llast() and the int and oid variant use a new inline function to get the last cell. I also pushed the resulting code to master. David
Commits
-
Add for_each_from, to simplify loops starting from non-first list cells.
- 56fe008996bc 14.0 landed
- 67b2ceea0157 13.1 landed
-
Minor mop-up for List improvements.
- 9d299a492454 14.0 landed
-
Improve pg_list.h's linitial(), lsecond() and co macros
- cc99baa43e0e 14.0 landed