agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use stack allocated StringInfoDatas, where possible
Date: Thu, 06 Nov 2025 02:00:08 +0000
Message-ID: <E1vGpIG-005Dnm-2W@gemulon.postgresql.org> (raw)

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

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(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1vGpIG-005Dnm-2W@gemulon.postgresql.org>
Permalink:  ../E1vGpIG-005Dnm-2W@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vGpIG-005Dnm-2W@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Use stack allocated StringInfoDatas, where possible
  In-Reply-To: <E1vGpIG-005Dnm-2W@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox