From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Use appendStringInfoSpaces more |
Date: | 2023-01-19 21:23:19 |
Message-ID: | CAHut+Pspx8K8GSVLH4UbvQffSJABbXwsYOH+0xB5jC61k-oUqw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jan 19, 2023 at 8:45 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> In [1] I noticed a bit of a poor usage of appendStringInfoString which
> just appends 4 spaces in a loop, one for each indent level of the
> jsonb. It should be better just to use appendStringInfoSpaces and
> just append all the spaces in one go rather than appending 4 spaces in
> a loop. That'll save having to check enlargeStringInfo() once for each
> loop.
>
Should the add_indent function also have a check to avoid making
unnecessary calls to appendStringInfoSpaces when the level is 0?
e.g.
if (indent)
{
appendStringInfoCharMacro(out, '\n');
if (level > 0)
appendStringInfoSpaces(out, level * 4);
}
V.
if (indent)
{
appendStringInfoCharMacro(out, '\n');
appendStringInfoSpaces(out, level * 4);
}
------
Kind Regards,
Peter Smith.
Fujitsu Australia
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-01-19 21:25:43 | Re: Use appendStringInfoSpaces more |
Previous Message | Peter Geoghegan | 2023-01-19 21:22:28 | Re: Decoupling antiwraparound autovacuum from special rules around auto cancellation |