Use stack allocated StringInfoDatas, where possible (round 2) - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Use stack allocated StringInfoDatas, where possible (round 2)
Date
Msg-id adt4wpj4FZwR+S7I@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
Responses Re: Use stack allocated StringInfoDatas, where possible (round 2)
List pgsql-hackers
Hi hackers,

Commit 6d0eba66275 already did most of the changes but missed the opportunities
to $SUBJECT in sequencesync.c.

Indeed, 5509055d6956 added a few cases that are using StringInfo but don't need
that StringInfo to exist beyond the scope of the function were using makeStringInfo(),
which allocates both a StringInfoData and the buffer it uses as two separate
allocations. It's more efficient for these cases to use a StringInfoData on the
stack and initialize it with initStringInfo(), which only allocates the string
buffer.

The reason 6d0eba66275 missed those is that 5509055d6956 has been committed
between the patch proposal for 6d0eba66275 and 6d0eba66275.

I used Mats's coccinelle script (mentioned in [1]) to find those and they are the
only remaining ones.

[1]: https://postgr.es/m/4379aac8-26f1-42f2-a356-ff0e886228d3%40gmail.com

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: SATYANARAYANA NARLAPURAM
Date:
Subject: Re: var_is_nonnullable() fails to handle invalid NOT NULL constraints
Next
From: Thomas Munro
Date:
Subject: ISBN range table