This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] C++-ify parse_format_string
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