Re: appendBinaryStringInfo stuff
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: David Rowley <dgrowleyml@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-12-20T21:43:58Z
Lists: 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
Commits
-
Change argument type of pq_sendbytes from char * to void *
- 3b12e68a5c46 16.0 landed
-
Remove useless casts to (void *) in hash_search() calls
- 54a177a948b0 16.0 cited
-
Change argument of appendBinaryStringInfo from char * to void *
- 1f605b82ba66 16.0 landed
-
Use appendStringInfoString instead of appendBinaryStringInfo where possible
- 33a33f0ba4d7 16.0 landed