Re: appendBinaryStringInfo stuff

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-12-19T20:23:09Z
Lists: pgsql-hackers
On 19.12.22 09:12, Andres Freund wrote:
>> There are a bunch of places in the json code that use
>> appendBinaryStringInfo() where appendStringInfoString() could be used, e.g.,
>>
>>      appendBinaryStringInfo(buf, ".size()", 7);
>>
>> Is there a reason for this?  Are we that stretched for performance?
> strlen() isn't that cheap, so it doesn't generally seem unreasonable. I
> don't think we should add the strlen overhead in places that can
> conceivably be a bottleneck - and some of the jsonb code clearly can be
> that.

AFAICT, the code in question is for the text output of the jsonpath 
type, which is used ... for barely anything?




Commits

  1. Change argument type of pq_sendbytes from char * to void *

  2. Remove useless casts to (void *) in hash_search() calls

  3. Change argument of appendBinaryStringInfo from char * to void *

  4. Use appendStringInfoString instead of appendBinaryStringInfo where possible