On Thu, Jan 19, 2023 at 8:45 PM David Rowley <dgrowle...@gmail.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