From: Simon Marchi <simark@simark.ca>
To: Pedro Alves <palves@redhat.com>,
Simon Marchi <simon.marchi@ericsson.com>,
Tom Tromey <tom@tromey.com>,
gdb-patches@sourceware.org
Subject: Re: [RFA] C++-ify parse_format_string
Date: Fri, 24 Nov 2017 03:17:00 -0000 [thread overview]
Message-ID: <d7a89d49-5cec-455c-25ca-7a3b9dafb1e3@simark.ca> (raw)
In-Reply-To: <0350cb5f-d176-76c4-11e8-5ffb3fe8c84d@redhat.com>
On 2017-11-23 05:40 PM, Pedro Alves wrote:
> On 11/23/2017 09:13 PM, Simon Marchi wrote:
>
>> I have a patch in some branch that does essentially the same thing, so
>> I was able to compare our approaches. In my version, I removed the
>> big allocation that is shared among pieces, and made each piece have
>> its own std::string. Unless we want to keep the current allocation
>> scheme for performance/memory usage reasons, I think that using
>> std::strings simplifies things in the parse_format_string function.
>> The format_pieces structure is replaced with an std::vector of
>> format_piece.
>
> Sounds like a step backwards to me. If it simplifies things, then
> it sounds like it might be because we're missing some utility,
> like string_view or something like that.
I am not sure I understand, can you expand a little bit about what you
have in mind?
What I meant is that is changes things like this:
strncpy (current_substring, percent_loc, length_before_ll);
strcpy (current_substring + length_before_ll, "I64");
current_substring[length_before_ll + 3] =
percent_loc[length_before_ll + lcount];
current_substring += length_before_ll + 4;
into this
piece_string.assign (percent_loc, length_before_ll);
piece_string += "I64";
piece_string += percent_loc[length_before_ll + lcount];
Less magical number, less playing with offsets, etc.
Simon
next prev parent reply other threads:[~2017-11-24 3:17 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 [this message]
2017-11-24 12:54 ` Pedro Alves
2017-11-24 16:26 ` Simon Marchi
2017-11-25 21:25 ` Tom Tromey
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=d7a89d49-5cec-455c-25ca-7a3b9dafb1e3@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.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).