From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 3/3] Make extract_arg return a std::string
Date: Mon, 11 Sep 2017 21:43:00 -0000 [thread overview]
Message-ID: <8760cohq89.fsf@bapiya> (raw)
In-Reply-To: <31794437bc5e56865f80cc72691899a4@polymtl.ca> (Simon Marchi's message of "Mon, 11 Sep 2017 21:51:57 +0200")
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
>> Change extract_arg to return a std::string and fix up all the users.
>> I think string is mildly better than unique_xmalloc_ptr<char>, when
>> possible, because it provides a more robust API.
Simon> I agree, for strings we allocate dynamically ourselves, it makes sense
Simon> to use std::string. For dynamically allocated strings coming from
Simon> external APIs we use, then unique_xmalloc_ptr<char> make sense, since
Simon> it doesn't require doing a copy. For things that are always
Simon> constant/literal strings, the const char *.
That's my thinking exactly.
It would be nice if string could adopt a unique_xmalloc_ptr. or we
could make string-returning variants of a few functions like
tilde_expand. On the callee side we could move to string_view in the
future.
Simon> It's a bit funny to refer to extract_arg when this function is also
Simon> named extract_arg. What about: "A const-correct version of the
Simon> above." ?
I've made this change in patch #1.
I made the other changes in this patch.
Tom
next prev parent reply other threads:[~2017-09-11 21:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 0:33 [RFA 0/3] preparation for command constification; cleanup removal Tom Tromey
2017-09-11 0:33 ` [RFA 3/3] Make extract_arg return a std::string Tom Tromey
2017-09-11 19:52 ` Simon Marchi
2017-09-11 21:43 ` Tom Tromey [this message]
2017-09-11 0:33 ` [RFA 2/3] Constify language_enum Tom Tromey
2017-09-11 19:17 ` Simon Marchi
2017-09-11 0:33 ` [RFA 1/3] Rename _const functions to use overloading instead Tom Tromey
2017-09-11 19:16 ` Simon Marchi
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=8760cohq89.fsf@bapiya \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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