Re: appendBinaryStringInfo stuff - Mailing list pgsql-hackers

From Robert Haas
Subject Re: appendBinaryStringInfo stuff
Date
Msg-id CA+TgmoZgjJQJCk=zF8m65S9beWvsjOQo1wWs1C8nOF5AsKe9nA@mail.gmail.com
Whole thread Raw
In response to Re: appendBinaryStringInfo stuff  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
On Tue, Dec 20, 2022 at 10:47 AM Andrew Dunstan <andrew@dunslane.net> wrote:
> There are 5 uses in the jsonb code where the length param is a compile
> time constant:
>
> andrew@ub22:adt $ grep appendBinary.*[0-9] jsonb*
> jsonb.c:            appendBinaryStringInfo(out, "null", 4);
> jsonb.c:                appendBinaryStringInfo(out, "true", 4);
> jsonb.c:                appendBinaryStringInfo(out, "false", 5);
> jsonb.c:                appendBinaryStringInfo(out, ": ", 2);
> jsonb.c:            appendBinaryStringInfo(out, "    ", 4);
>
> None of these really bother me much, TBH. In fact the last one is
> arguably nicer because it tells you without counting how many spaces
> there are.

+1. There are certainly cases where this kind of style can create
confusion, but I have a hard time putting any of these instances into
that category. It's obvious at a glance that null is 4 bytes, false is
5, etc.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Minimal logical decoding on standbys
Next
From: Eric Radman
Date:
Subject: [PATCH] Add function to_oct