public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
To: Tom Tromey <tom@tromey.com>
Cc: Andrew Burgess <andrew.burgess@embecosm.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] gdb: Convert completion tracker to use std types
Date: Fri, 24 Jan 2020 19:47:00 -0000	[thread overview]
Message-ID: <CAPTJ0XEaHCvKrYcMNkoKonbnvOzqmfvnQv6wSDQAKyMhH3DLKA@mail.gmail.com> (raw)
In-Reply-To: <87pnf88z3o.fsf@tromey.com>

On Fri, Jan 24, 2020, 20:14 Tom Tromey <tom@tromey.com> wrote:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
>
> Andrew> For now then I'm holding the raw 'char *' within the unordered_map,
> Andrew> and rely on the completion_tracker object to delete the data if
> Andrew> needed, or to ensure that the data is passed over to readline,
> which
> Andrew> will do the deletion for us.
>
> Seems reasonable enough.
>
> Andrew> +  for (const auto &p : m_entries_hash)
> Andrew> +    {
> Andrew> +      xfree ((char *) p.first);
> Andrew> +      xfree ((char *) p.second);
>
> Maybe const_cast would be better?
>
> Andrew> +  /* A map of completions.  The key is the completion, and the
> value is the
> Andrew> +     string to be used to compute the lowest common denominator.
> Both the
> Andrew> +     key and the value are owned by the completion_tracker class
> while
> Andrew> +     being held in this map, as such completion_tracker must free
> these
> Andrew> +     strings when finished with them, or pass ownership to
> someone else who
> Andrew> +     will free them.  */
> Andrew> +  typedef std::unordered_map<const char *, const char *,
> std::hash<std::string>,
> Andrew> +                            std::equal_to<std::string>>
> completion_set;
>
> Does using std::string here mean that a temporary std::string will be
> made for each insertion in the map?  And also for comparisons?
> That seems expensive if so.
>

Perhaps that's finally a use case to add hash<gdb::string_view>!


> Tom
>

  reply	other threads:[~2020-01-24 19:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28  0:37 [PATCHv2 0/3] Remove C++ Symbol Aliases From Completion List Andrew Burgess
2019-12-27 21:32 ` [PATCH 0/2] " Andrew Burgess
2019-12-27 21:32   ` [PATCH 2/2] gdb: Remove C++ symbol aliases from completion list Andrew Burgess
2020-01-24 19:08     ` Tom Tromey
2019-12-27 21:32   ` [PATCH 1/2] gdb: Convert completion tracker to use std types Andrew Burgess
2020-01-24 19:18     ` Tom Tromey
2020-01-24 19:47       ` Christian Biesinger via gdb-patches [this message]
2020-01-26 16:01         ` Tom Tromey
2020-01-28  0:37   ` [PATCHv2 3/3] gdb: Remove C++ symbol aliases from completion list Andrew Burgess
2020-05-24 11:35     ` Pedro Alves
2020-05-24 12:34       ` [pushed] Don't remove C++ aliases from completions if symbol doesn't match (Re: [PATCHv2 3/3] gdb: Remove C++ symbol aliases from completion list) Pedro Alves
2020-05-25 14:34       ` GDB crash due to infinite recursion in typedef substitution " Pedro Alves
2020-05-26 17:02         ` Andrew Burgess
2020-05-26 18:09           ` Pedro Alves
2020-05-26 21:17         ` Keith Seitz
2020-05-27 19:36           ` Pedro Alves
2020-05-28 13:40             ` Pedro Alves
2020-01-28  0:37   ` [PATCHv2 2/3] gdb: Restructure the completion_tracker class Andrew Burgess
2020-04-03 23:00     ` Luis Machado
2020-04-04 15:37       ` [PATCH] gdb: Don't corrupt completions hash when expanding the hash table Andrew Burgess
2020-04-06 20:27         ` Tom Tromey
2020-04-15 15:46           ` Andrew Burgess
2020-01-28  0:50   ` [PATCHv2 1/3] libiberty/hashtab: More const parameters Andrew Burgess
2020-02-25 17:35     ` Andrew Burgess
2020-03-12 10:33 ` [PATCHv2 0/3] Remove C++ Symbol Aliases From Completion List Andrew Burgess
2020-03-12 19:17   ` 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=CAPTJ0XEaHCvKrYcMNkoKonbnvOzqmfvnQv6wSDQAKyMhH3DLKA@mail.gmail.com \
    --to=gdb-patches@sourceware.org \
    --cc=andrew.burgess@embecosm.com \
    --cc=cbiesinger@google.com \
    --cc=tom@tromey.com \
    /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).