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 <[email protected]> Reviewed-by: David Rowley <[email protected]> Reviewed-by: Chao Li <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/6d0eba66275b125bf634bbdffda90c70856e3f93 Modified Files -------------- contrib/postgres_fdw/postgres_fdw.c | 14 ++++----- contrib/tcn/tcn.c | 19 ++++++------ src/backend/access/transam/xlogbackup.c | 34 ++++++++++----------- src/backend/backup/basebackup.c | 10 +++---- src/backend/commands/subscriptioncmds.c | 35 ++++++++++++---------- src/backend/utils/adt/json.c | 53 +++++++++++++++++---------------- src/backend/utils/adt/jsonb.c | 9 +++--- src/backend/utils/adt/jsonfuncs.c | 18 +++++++---- src/backend/utils/adt/multirangetypes.c | 13 ++++---- src/backend/utils/adt/rangetypes.c | 18 ++++++----- src/backend/utils/adt/ruleutils.c | 17 ++++++----- src/backend/utils/adt/xml.c | 34 ++++++++++----------- 12 files changed, 144 insertions(+), 130 deletions(-)
