public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] [gdb/symtab] Malloc/free less in parse_macro_definition
Date: Mon, 24 Jun 2024 12:20:10 -0600	[thread overview]
Message-ID: <877ceetd7p.fsf@tromey.com> (raw)
In-Reply-To: <20240624081427.13495-2-tdevries@suse.de> (Tom de Vries's message of "Mon, 24 Jun 2024 10:14:27 +0200")

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> +/* Vector of C strings.  Allows to push a string_view-like string while
Tom> +   managing the memory required for that.  */
Tom> +
Tom> +class vector_c_string : public std::vector<const char *>

I think it's generally considered bad practice to inherit from std
types.

Tom> +  /* By making this static we share allocation between invocations.  */
Tom> +  static vector_c_string argv;

I think we should avoid static locals.  For one thing they inhibit our
ability to use threads.

If allocation is a performance issue or something then maybe the storage
can be hoisted to some more-outer function somewhere.

I wonder if this could share some code with:

https://inbox.sourceware.org/gdb-patches/20240426154439.94728-1-tromey@adacore.com/

Like maybe a different refactoring is in order.

Tom

  reply	other threads:[~2024-06-24 18:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24  8:14 [PATCH 1/2] [gdb/symtab] Remove dead code " Tom de Vries
2024-06-24  8:14 ` [PATCH 2/2] [gdb/symtab] Malloc/free less " Tom de Vries
2024-06-24 18:20   ` Tom Tromey [this message]
2024-06-26  6:33     ` Tom de Vries
2024-06-24 13:08 ` [PATCH 1/2] [gdb/symtab] Remove dead code " Alexandra Petlanova Hajkova
2024-06-24 18:23 ` Tom Tromey

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877ceetd7p.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).