pgsql: Use stack allocated StringInfoDatas, where possible
pgsql: Use stack allocated StringInfoDatas, where possible
От:
David Rowley <drowley@postgresql.org>
Дата:
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 Reviewed-by: David Rowley Reviewed-by: Chao Li Discussion: https://postgr.es/m/4379aac8-26f1-42f2-a356-ff0e886228d3@gmail.com 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(-)