Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simark@simark.ca>,
	 Simon Marchi <simon.marchi@ericsson.com>,
	 Tom Tromey <tom@tromey.com>,
	 gdb-patches@sourceware.org
Subject: Re: [RFA] C++-ify parse_format_string
Date: Sat, 25 Nov 2017 21:25:00 -0000	[thread overview]
Message-ID: <87h8tivyo4.fsf@tromey.com> (raw)
In-Reply-To: <b2308402-c29b-5e7e-c721-660c83b0d591@redhat.com> (Pedro Alves's	message of "Fri, 24 Nov 2017 12:54:33 +0000")

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I call it a step backwards because simplification is done at the
Pedro> cost of efficiency (individual heap allocations, changing the
Pedro> ownership model), when the original code avoided that.

I agree with this principle in general, but I think that in this
particular case, the efficiency and/or allocation argument is not very
strong -- I just doubt this code is space- or time-sensitive.

So on the whole I think in this case it would be fine to use Simon's
patch.

Pedro> [1] - I've thought several times because that something like a zstring_view
Pedro> (like string_view, but guarantees null-termination) would be handy in
Pedro> a lot of places.  string_view isn't mutable, though, hence the
Pedro> alternative name instead.  could be mut_string_view too, for example.

In gdb I've often wanted something like "std::string API but
unique_xmalloc_ptr allocation policy".  That way one could get the handy
string methods but allow nicer interfacing to things already using
xmalloc (I guess primarily libiberty but also readline and sometimes
BFD).

The main danger I see of views is that then one must reason about
lifetimes in order to use them.  But in gdb maybe this can be handled
via some relatively simple rules, like "never store a view on the heap".

Tom


  parent reply	other threads:[~2017-11-25 21:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 16:46 Tom Tromey
2017-11-23 21:14 ` Simon Marchi
2017-11-23 22:40   ` Pedro Alves
2017-11-24  3:17     ` Simon Marchi
2017-11-24 12:54       ` Pedro Alves
2017-11-24 16:26         ` Simon Marchi
2017-11-25 21:25         ` Tom Tromey [this message]
2017-12-02 20:31           ` [PATCH] " Simon Marchi
2017-12-03 14:12             ` Pedro Alves
2017-12-03 17:50               ` Simon Marchi
2017-12-08 16:22                 ` 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=87h8tivyo4.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=simark@simark.ca \
    --cc=simon.marchi@ericsson.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