Re: Convert macros to static inline functions - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Convert macros to static inline functions
Date
Msg-id 202205161548.7cjsl2hdmhas@alvherre.pgsql
Whole thread Raw
In response to Re: Convert macros to static inline functions  (Amul Sul <sulamul@gmail.com>)
List pgsql-hackers
On 2022-May-16, Amul Sul wrote:

> +static inline OffsetNumber
> +PageGetMaxOffsetNumber(Page page)
> +{
> +   if (((PageHeader) page)->pd_lower <= SizeOfPageHeaderData)
> +       return 0;
> +   else
> +       return ((((PageHeader) page)->pd_lower - SizeOfPageHeaderData)
> / sizeof(ItemIdData));
> +}
> 
> The "else" is not necessary, we can have the return statement directly
> which would save some indentation as well. The Similar pattern can be
> considered for 0004 and 0007 patches as well.

Yeah.  In these cases I propose to also have a local variable so that
the cast to PageHeader appears only once.


-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [RFC] building postgres with meson -v8
Next
From: Justin Pryzby
Date:
Subject: Re: First draft of the PG 15 release notes