Re: Use appendStringInfoSpaces more - Mailing list pgsql-hackers

From David Rowley
Subject Re: Use appendStringInfoSpaces more
Date
Msg-id CAApHDvon2EoCh-Os98dvcMfGzyeo53ru7YGdXmmbPjm3Bmmstg@mail.gmail.com
Whole thread Raw
In response to Re: Use appendStringInfoSpaces more  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, 20 Jan 2023 at 10:25, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Peter Smith <smithpb2250@gmail.com> writes:
> > Should the add_indent function also have a check to avoid making
> > unnecessary calls to appendStringInfoSpaces when the level is 0?
>
> Seems like unnecessary extra notation, seeing that appendStringInfoSpaces
> will fall out quickly for a zero argument.

Yeah agreed. As far as I see it, the level will only be 0 before the
first WJB_BEGIN_OBJECT and those appear to be the first thing in the
document, so we'll only indent level 0 once and everything else will
be > 0. So, it also seems to me that the additional check is more
likely to cost more than it would save.

David



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Decoupling antiwraparound autovacuum from special rules around auto cancellation
Next
From: Tom Lane
Date:
Subject: Re: Fix GetWALAvailability function code comments for WALAVAIL_REMOVED return value