Re: [PATCH] Simplify trivial shmem size calculations

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Junwang Zhao <zhjwpku(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Simplify trivial shmem size calculations
Date: 2026-03-11 00:21:58
Message-ID: CAHewXN=haH3hw_X06UyHE2t9KjzFFKTcX2KQXz427YJ2aekLOA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Junwang Zhao <zhjwpku(at)gmail(dot)com> 于2026年3月10日周二 21:32写道:

> > And I also found another case:
> > Size
> > XLogRecoveryShmemSize(void)
> > {
> > Size size;
> >
> > /* XLogRecoveryCtl */
> > size = sizeof(XLogRecoveryCtlData);
> >
> > return size;
> > }
> >
> > The above code does not need to define the local variable size;
> > directly returning sizeof(XLogRecoveryCtlData) seems simpler.
>
> I bet the compiler will optimize it away.

Yeah, XLogRecoveryShmemSize() may be optimized by the compiler, I only
want the codes to look more consistent.

>I think it's fine as it is.
Ok.

--
Thanks,
Tender Wang

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-03-11 00:43:02 Re: Remove header lock BufferGetLSNAtomic() on architectures with 64 bit atomic operations
Previous Message Andres Freund 2026-03-11 00:16:50 Re: Streamify more code paths