]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Use stack allocated StringInfoDatas, where possible
authorDavid Rowley <drowley@postgresql.org>
Thu, 6 Nov 2025 01:59:48 +0000 (14:59 +1300)
committerDavid Rowley <drowley@postgresql.org>
Thu, 6 Nov 2025 01:59:48 +0000 (14:59 +1300)
commit6d0eba66275b125bf634bbdffda90c70856e3f93
treee8457e698dcb49a6f9591e79373d8dfddd617f9e
parentcf638b46aff2ccb8d4811e3b5d8a2c2410638190
Use stack allocated StringInfoDatas, where possible

Various places that were using StringInfo but didn'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.  This also simplifies the cleanup,
in a few cases.

Author: Mats Kindahl <mats.kindahl@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/4379aac8-26f1-42f2-a356-ff0e886228d3@gmail.com
12 files changed:
contrib/postgres_fdw/postgres_fdw.c
contrib/tcn/tcn.c
src/backend/access/transam/xlogbackup.c
src/backend/backup/basebackup.c
src/backend/commands/subscriptioncmds.c
src/backend/utils/adt/json.c
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/multirangetypes.c
src/backend/utils/adt/rangetypes.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/xml.c