Re: micro-optimizing json.c - Mailing list pgsql-hackers

From John Naylor
Subject Re: micro-optimizing json.c
Date
Msg-id CANWCAZapSoHibA2fPZhfaDbN_vEsc8G_MH=fzpTs5TMixSPoyA@mail.gmail.com
Whole thread Raw
In response to Re: micro-optimizing json.c  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: micro-optimizing json.c
List pgsql-hackers
On Fri, Dec 8, 2023 at 10:32 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
>
> On Fri, Dec 08, 2023 at 04:11:52PM +1300, David Rowley wrote:
> > + seplen = use_line_feeds ? sizeof(",\n ") - 1 : sizeof(",") - 1;
> >
> > Most modern compilers will be fine with just:
> >
> > seplen = strlen(sep);
> >
> > I had to go back to clang 3.4.1 and GCC 4.1.2 to see the strlen() call
> > with that code [1].
>
> Hm.  I tried this first, but my compiler (gcc 9.4.0 on this machine) was
> still doing the strlen()...

This is less verbose and still compiles with constants:

use_line_feeds ? strlen(",\n ") : strlen(",");



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Is WAL_DEBUG related code still relevant today?
Next
From: Ashutosh Bapat
Date:
Subject: Re: Memory consumed by paths during partitionwise join planning