Re: Convert macros to static inline functions
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-06-09T02:01:56Z
Lists: pgsql-hackers
On Mon, May 16, 2022 at 1:28 AM Peter Eisentraut <peter.eisentraut@enterprisedb.com> wrote: > Inspired by [0], I looked to convert more macros to inline functions. > The attached patches are organized "bottom up" in terms of their API > layering; some of the later ones depend on some of the earlier ones. Big +1 from me. I converted over most of the nbtree.h function style macros in Postgres 13, having put it off in Postgres 12 (there is one remaining function macro due to an issue with #include dependencies). This vastly improved the maintainability of the code, and I wish I'd done it sooner. Inline functions made it a lot easier to pepper various B-Tree code utility functions with defensive assertions concerning preconditions and postconditions. That's something that I am particular about. In theory you can just use AssertMacro() in a function style macro. In practice that approach is ugly, and necessitates thinking about multiple evaluation hazards, which is enough to discourage good defensive coding practices. -- Peter Geoghegan
Commits
-
Add some const decorations (htup.h)
- b15b8c5cf882 18.0 landed
-
Convert macros to static inline functions (htup_details.h, itup.h)
- 34694ec888d6 18.0 landed
-
Convert macros to static inline functions (rel.h)
- 3edc71ec0438 16.0 landed
-
Convert macros to static inline functions (itup.h)
- 14a8bd98274a 16.0 landed
-
Convert macros to static inline functions (tupmacs.h)
- f58d7073b775 16.0 landed
-
Convert macros to static inline functions (xlog_internal.h)
- 507ba16b28c7 16.0 landed
-
Convert macros to static inline functions (bufmgr.h)
- 9c727360bcc7 16.0 landed
-
Convert macros to static inline functions (itemptr.h)
- aeb767ca0b02 16.0 landed
-
Convert macros to static inline functions (bufpage.h)
- 2cd2569c72b8 16.0 landed
-
Convert macros to static inline functions (block.h)
- d63d957e330c 16.0 landed