Re: Use appendStringInfoSpaces more

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use appendStringInfoSpaces more
Date: 2023-01-19 23:41:29
Message-ID: CAApHDvon2EoCh-Os98dvcMfGzyeo53ru7YGdXmmbPjm3Bmmstg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 20 Jan 2023 at 10:25, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Peter Smith <smithpb2250(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-01-19 23:43:52 Re: Fix GetWALAvailability function code comments for WALAVAIL_REMOVED return value
Previous Message Andres Freund 2023-01-19 23:38:57 Re: Decoupling antiwraparound autovacuum from special rules around auto cancellation